cxf-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sergey Beryozkin <sberyoz...@gmail.com>
Subject Re: svn commit: r1539911 - in /cxf/trunk: parent/ rt/frontend/jaxrs/ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/swagger/
Date Fri, 08 Nov 2013 11:39:35 GMT
I'm sorry, really not sure how I got my message truncated

Yes, please move it rt/rs/description - this is now where WADL related 
code lives, I'm fine with Swagger code being there too

Sergey

On 08/11/13 11:32, Sergey Beryozkin wrote:
> Hi Freeman
>
> While I appreciate yout effort I'm -1 on this commit.
> Here is why:
>
> - we've worked hard on minimizing cxf rt frontend jaxrs and in one ho
> you add a Swagger related code without even discussing it.
>
> Please revert your commits.
>
> IMHO, it may go as an *optional* dependency to rt/rs/description module
> which is where it should stay, on the trunk only. I honestly do not want
>
>
>
>
> On 08/11/13 03:30, ffang@apache.org wrote:
>> Author: ffang
>> Date: Fri Nov  8 03:30:41 2013
>> New Revision: 1539911
>>
>> URL: http://svn.apache.org/r1539911
>> Log:
>> [CXF-5379]introduce cxf swagger feature
>>
>> Added:
>>
>> cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/swagger/
>>
>> cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/swagger/SwaggerFeature.java
>>
>> Modified:
>>      cxf/trunk/parent/pom.xml
>>      cxf/trunk/rt/frontend/jaxrs/pom.xml
>>
>> cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/AbstractJAXRSFactoryBean.java
>>
>>
>> Modified: cxf/trunk/parent/pom.xml
>> URL:
>> http://svn.apache.org/viewvc/cxf/trunk/parent/pom.xml?rev=1539911&r1=1539910&r2=1539911&view=diff
>>
>> ==============================================================================
>>
>> --- cxf/trunk/parent/pom.xml (original)
>> +++ cxf/trunk/parent/pom.xml Fri Nov  8 03:30:41 2013
>> @@ -149,6 +149,7 @@
>>           <cxf.spring.osgi.version>1.2.1</cxf.spring.osgi.version>
>>
>> <cxf.spring.ldap.version>1.3.1.RELEASE</cxf.spring.ldap.version>
>>           <cxf.spring.mock>spring-test</cxf.spring.mock>
>> +        <cxf.swagger.version>1.3.0</cxf.swagger.version>
>>           <cxf.velocity.version>1.7</cxf.velocity.version>
>>           <cxf.woodstox.core.version>4.2.0</cxf.woodstox.core.version>
>>
>> <cxf.woodstox.stax2-api.version>3.1.1</cxf.woodstox.stax2-api.version>
>> @@ -1615,6 +1616,12 @@
>>                   <artifactId>msv-core</artifactId>
>>                   <version>${cxf.msv.version}</version>
>>               </dependency>
>> +            <dependency>
>> +                <groupId>com.wordnik</groupId>
>> +                <artifactId>swagger-jaxrs_2.10</artifactId>
>> +                <version>${cxf.swagger.version}</version>
>> +            </dependency>
>> +
>>           </dependencies>
>>       </dependencyManagement>
>>
>>
>> Modified: cxf/trunk/rt/frontend/jaxrs/pom.xml
>> URL:
>> http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/pom.xml?rev=1539911&r1=1539910&r2=1539911&view=diff
>>
>> ==============================================================================
>>
>> --- cxf/trunk/rt/frontend/jaxrs/pom.xml (original)
>> +++ cxf/trunk/rt/frontend/jaxrs/pom.xml Fri Nov  8 03:30:41 2013
>> @@ -36,6 +36,7 @@
>>               javax.servlet*;version="${cxf.osgi.javax.servlet.version}",
>>               org.apache.aries*;version="${cxf.aries.version.range}",
>>
>> org.springframework*;resolution:="optional";version="${cxf.osgi.spring.version}",
>>
>> +
>> com.wordnik.swagger.jaxrs*;resolution:="optional";version="[1.3.0,
>> 1.4.0)",
>>               javax.ws.rs.client;version="[2.0,3)",
>>               javax.ws.rs*;version="[1.0,3)",
>>           </cxf.osgi.import>
>> @@ -158,6 +159,10 @@
>>                   </exclusion>
>>               </exclusions>
>>           </dependency>
>> +        <dependency>
>> +            <groupId>com.wordnik</groupId>
>> +            <artifactId>swagger-jaxrs_2.10</artifactId>
>> +        </dependency>
>>       </dependencies>
>>
>>
>>
>> Modified:
>> cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/AbstractJAXRSFactoryBean.java
>>
>> URL:
>> http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/AbstractJAXRSFactoryBean.java?rev=1539911&r1=1539910&r2=1539911&view=diff
>>
>> ==============================================================================
>>
>> ---
>> cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/AbstractJAXRSFactoryBean.java
>> (original)
>> +++
>> cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/AbstractJAXRSFactoryBean.java
>> Fri Nov  8 03:30:41 2013
>> @@ -110,6 +110,7 @@ public class AbstractJAXRSFactoryBean ex
>>           super.setBus(bus);
>>           checkBindingFactory(bus);
>>           serviceFactory.setBus(bus);
>> +        bus.setProperty(JAXRSServiceFactoryBean.class.getName(),
>> serviceFactory);
>>       }
>>
>>       /*
>> @@ -204,6 +205,7 @@ public class AbstractJAXRSFactoryBean ex
>>        */
>>       public void setServiceFactory(JAXRSServiceFactoryBean
>> serviceFactory) {
>>           this.serviceFactory = serviceFactory;
>> +        getBus().setProperty(JAXRSServiceFactoryBean.class.getName(),
>> serviceFactory);
>>       }
>>
>>       protected Endpoint createEndpoint() throws BusException,
>> EndpointException {
>>
>> Added:
>> cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/swagger/SwaggerFeature.java
>>
>> URL:
>> http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/swagger/SwaggerFeature.java?rev=1539911&view=auto
>>
>> ==============================================================================
>>
>> ---
>> cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/swagger/SwaggerFeature.java
>> (added)
>> +++
>> cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/swagger/SwaggerFeature.java
>> Fri Nov  8 03:30:41 2013
>> @@ -0,0 +1,142 @@
>> +/**
>> + * Licensed to the Apache Software Foundation (ASF) under one
>> + * or more contributor license agreements. See the NOTICE file
>> + * distributed with this work for additional information
>> + * regarding copyright ownership. The ASF licenses this file
>> + * to you under the Apache License, Version 2.0 (the
>> + * "License"); you may not use this file except in compliance
>> + * with the License. You may obtain a copy of the License at
>> + *
>> + * http://www.apache.org/licenses/LICENSE-2.0
>> + *
>> + * Unless required by applicable law or agreed to in writing,
>> + * software distributed under the License is distributed on an
>> + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
>> + * KIND, either express or implied. See the License for the
>> + * specific language governing permissions and limitations
>> + * under the License.
>> + */
>> +package org.apache.cxf.jaxrs.swagger;
>> +
>> +import java.util.ArrayList;
>> +import java.util.List;
>> +
>> +import org.apache.cxf.Bus;
>> +import org.apache.cxf.endpoint.Server;
>> +import org.apache.cxf.feature.AbstractFeature;
>> +import org.apache.cxf.jaxrs.JAXRSServiceFactoryBean;
>> +import org.apache.cxf.jaxrs.model.AbstractResourceInfo;
>> +import org.apache.cxf.jaxrs.provider.ProviderFactory;
>> +
>> +public class SwaggerFeature extends AbstractFeature {
>> +
>> +    private String resourcePackage;
>> +    private String version = "1.0.0";
>> +    private String basePath;
>> +    private String title = "Rest sample app";
>> +    private String description = "This is a app.";
>> +    private String contact = "freeman.fang@gmail.com";
>> +    private String license = "Apache 2.0 License";
>> +    private String licenseUrl =
>> "http://www.apache.org/licenses/LICENSE-2.0.html";
>> +    private boolean scan = true;
>> +    @Override
>> +    public void initialize(Server server, Bus bus) {
>> +        List<Object> serviceBeans = new ArrayList<Object>();
>> +        serviceBeans.add(new
>> com.wordnik.swagger.jaxrs.listing.ApiListingResourceJSON());
>> +        calulateDefaultResourcePackage(bus);
>> +        calulateDefaultBasePath(server);
>> +
>> ((JAXRSServiceFactoryBean)bus.getProperty(JAXRSServiceFactoryBean.class.getName())).
>>
>> +            setResourceClassesFromBeans(serviceBeans);
>> +        List<Object> providers = new ArrayList<Object>();
>> +        providers.add(new
>> com.wordnik.swagger.jaxrs.listing.ResourceListingProvider());
>> +        providers.add(new
>> com.wordnik.swagger.jaxrs.listing.ApiDeclarationProvider());
>> +
>> ((ProviderFactory)bus.getProperty(ProviderFactory.class.getName())).setUserProviders(providers);
>>
>> +        com.wordnik.swagger.jaxrs.config.BeanConfig beanConfig = new
>> com.wordnik.swagger.jaxrs.config.BeanConfig();
>> +        beanConfig.setResourcePackage(getResourcePackage());
>> +        beanConfig.setVersion(getVersion());
>> +        beanConfig.setBasePath(getBasePath());
>> +        beanConfig.setTitle(getTitle());
>> +        beanConfig.setDescription(getDescription());
>> +        beanConfig.setContact(getContact());
>> +        beanConfig.setLicense(getLicense());
>> +        beanConfig.setLicenseUrl(getLicenseUrl());
>> +        beanConfig.setScan(isScan());
>> +        initializeProvider(server.getEndpoint(), bus);
>> +    }
>> +    private void calulateDefaultResourcePackage(Bus bus) {
>> +        JAXRSServiceFactoryBean serviceFactoryBean =
>> +
>> (JAXRSServiceFactoryBean)bus.getProperty(JAXRSServiceFactoryBean.class.getName());
>>
>> +        AbstractResourceInfo resourceInfo =
>> serviceFactoryBean.getClassResourceInfo().get(0);
>> +
>> +        if ((resourceInfo != null)
>> +            && (getResourcePackage() == null ||
>> getResourcePackage().length() == 0)) {
>> +
>> setResourcePackage(resourceInfo.getResourceClass().getPackage().getName());
>>
>> +        }
>> +    }
>> +
>> +    private void calulateDefaultBasePath(Server server) {
>> +        String address =
>> server.getEndpoint().getEndpointInfo().getAddress();
>> +        if (getBasePath() == null || getBasePath().length() == 0) {
>> +            if (address.startsWith("http")) {
>> +                setBasePath(address + "/api-docs");
>> +            } else {
>> +                setBasePath("http://localhost:8181/cxf" + address +
>> "/api-docs");
>> +            }
>> +        }
>> +    }
>> +    public String getResourcePackage() {
>> +        return resourcePackage;
>> +    }
>> +    public void setResourcePackage(String resourcePackage) {
>> +        this.resourcePackage = resourcePackage;
>> +    }
>> +    public String getVersion() {
>> +        return version;
>> +    }
>> +    public void setVersion(String version) {
>> +        this.version = version;
>> +    }
>> +    public String getBasePath() {
>> +        return basePath;
>> +    }
>> +    public void setBasePath(String basePath) {
>> +        this.basePath = basePath;
>> +    }
>> +    public String getTitle() {
>> +        return title;
>> +    }
>> +    public void setTitle(String title) {
>> +        this.title = title;
>> +    }
>> +    public String getDescription() {
>> +        return description;
>> +    }
>> +    public void setDescription(String description) {
>> +        this.description = description;
>> +    }
>> +    public String getContact() {
>> +        return contact;
>> +    }
>> +    public void setContact(String contact) {
>> +        this.contact = contact;
>> +    }
>> +    public String getLicense() {
>> +        return license;
>> +    }
>> +    public void setLicense(String license) {
>> +        this.license = license;
>> +    }
>> +    public String getLicenseUrl() {
>> +        return licenseUrl;
>> +    }
>> +    public void setLicenseUrl(String licenseUrl) {
>> +        this.licenseUrl = licenseUrl;
>> +    }
>> +    public boolean isScan() {
>> +        return scan;
>> +    }
>> +    public void setScan(boolean scan) {
>> +        this.scan = scan;
>> +    }
>> +
>> +}
>>
>>
>
>


-- 
Sergey Beryozkin

Talend Community Coders
http://coders.talend.com/

Blog: http://sberyozkin.blogspot.com

Mime
View raw message