I see this issue is being addressed in
https://github.com/swagger-api/swagger-codegen/issues/4447
Looks like the fix will be in codegen v2.2.2.
On Wednesday, 8 February 2017 13:20:36 UTC+2, Derek Scotney wrote:
>
> It looks like the problem arises from the fact that when Swagger Codegen
> creates the API java files from the swagger.json file, it doesn't include
> the necessary @Api annotations. It seems insane to me that I need to edit
> the auto-generated classes to insert annotations to make Swagger work.
>
> On Tuesday, 7 February 2017 11:29:37 UTC+2, Derek Scotney wrote:
>>
>> Hi
>>
>> I added all my generated class files, however I got the same result. I
>> know that the class files were parsed as I accidentally added some files
>> without the @Path and the deployment broke when these files were read.
>>
>> *{"swagger":"2.0","info":{"version":"1.0.0","title":"RESTful
>> Webservice"},"host":"localhost:8080","basePath":"/rest","schemes":["http"]}*
>>
>> Since I already have a pre-built swagger.json file (from which the api
>> and model is generated), is it not possible for this to be used for the
>> swagger-ui docs? Having said that, I willing to implement whatever works
>> (other than using Spring) :)
>>
>>
>> On Monday, 6 February 2017 22:18:49 UTC+2, tony tam wrote:
>>>
>>> Try adding your class package to this section in your web.xml:
>>>
>>> <context-param>
>>> <param-name>resteasy.resources</param-name>
>>> <param-value>
>>> io.swagger.jaxrs.listing.ApiListingResource,
>>> io.swagger.jaxrs.listing.AcceptHeaderApiListingResource
>>> </param-value>
>>> </context-param>
>>>
>>>
>>> That’s where the swagger framework looks for classes to scan.
>>>
>>>
>>> On Feb 6, 2017, at 4:44 AM, Derek Scotney <[email protected]> wrote:
>>>
>>> Hi
>>>
>>> I know this topic (or similar) seems to have been raised in many forums.
>>> I have tried so many different "solutions", but nothing is working for me.
>>> The scenario is that I have created a swagger.json file describing my
>>> RESTful API and using the "swagger-codegen-maven-plugin", I have generated
>>> the java code (maven setup below). This worked flawlessly.
>>>
>>> <plugin>
>>> <groupId>io.swagger</groupId>
>>> <artifactId>swagger-codegen-maven-plugin</artifactId>
>>> <version>2.2.1</version>
>>> <executions>
>>> <execution>
>>> <goals>
>>> <goal>generate</goal>
>>> </goals>
>>> <configuration>
>>>
>>> <inputSpec>${project.basedir}/src/main/webapp/swagger.json</inputSpec>
>>> <language>jaxrs-resteasy</language>
>>> <output>${project.build.directory}/generated-sources</output>
>>> <configOptions>
>>> <sourceFolder>src/main/java</sourceFolder>
>>> <invokerPackage>za.co.company.ws.rest</invokerPackage>
>>> <apiPackage>za.co.company.ws.rest.api</apiPackage>
>>> <modelPackage>za.co.company.ws.rest.model</modelPackage>
>>> </configOptions>
>>> </configuration>
>>> </execution>
>>> </executions>
>>> </plugin>
>>>
>>> I also have the following dependencies:
>>> - "swagger-jaxrs" v1.5.12
>>> - "swagger-ui" v2.2.10 (I'm not sure if this necessary, but anyway)
>>>
>>> I can build this code, deploy it in JBoss and access the endpoints with
>>> the auto-generated responses. PERFECT.
>>>
>>> I would now like to view the Swagger UI docs for the API (i.e. like with
>>> the sample PetStore app). To use use swagger-ui, I have followed the
>>> installation method of copying the contents of the "dist" directory of the
>>> swagger-ui project into my project src/main/webapp/swagger directory, and
>>> modify the line in the index.html file "url = "
>>> http://petstore.swagger.io/v2/swagger.json";" to reflect my own path to
>>> the swagger.json file (url = "http://localhost:8080/rest/swagger.json";).
>>> My swagger.json resides in the src/main/webapp.
>>>
>>> My *web.xml* file contains (as per information obtained from
>>> https://github.com/swagger-api/swagger-core/wiki/1.3--1.5-Migration )
>>>
>>> <?xml version="1.0" encoding="ISO-8859-1"?>
>>> <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
>>> xmlns:j2ee="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="
>>> http://www.w3.org/2001/XMLSchema-instance"
>>> xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
>>> http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
>>>
>>> <display-name>RESTful Webservice</display-name>
>>>
>>> <context-param>
>>> <param-name>resteasy.resources</param-name>
>>> <param-value>
>>> io.swagger.jaxrs.listing.ApiListingResource,
>>> io.swagger.jaxrs.listing.AcceptHeaderApiListingResource
>>> </param-value>
>>> </context-param>
>>>
>>> <context-param>
>>> <param-name>resteasy.providers</param-name>
>>>
>>> <param-value>io.swagger.jaxrs.listing.SwaggerSerializers</param-value>
>>> </context-param>
>>>
>>> <servlet>
>>> <servlet-name>DefaultJaxrsConfig</servlet-name>
>>>
>>> <servlet-class>io.swagger.jaxrs.config.DefaultJaxrsConfig</servlet-class>
>>> <init-param>
>>> <param-name>api.version</param-name>
>>> <param-value>1.0.0</param-value>
>>> </init-param>
>>> <init-param>
>>> <param-name>swagger.api.title</param-name>
>>> <param-value>RESTful Webservice</param-value>
>>> </init-param>
>>> <init-param>
>>> <param-name>swagger.api.basepath</param-name>
>>> <param-value>http://localhost:8080/Srest</param-value>
>>> </init-param>
>>> <load-on-startup>2</load-on-startup>
>>> </servlet>
>>>
>>> <filter>
>>> <filter-name>ApiOriginFilter</filter-name>
>>>
>>> <filter-class>za.co.smartcall.ws.rest.api.ApiOriginFilter</filter-class>
>>> </filter>
>>> <filter-mapping>
>>> <filter-name>ApiOriginFilter</filter-name>
>>> <url-pattern>/*</url-pattern>
>>> </filter-mapping>
>>>
>>> </web-app>
>>>
>>> With this configuration, I can call each endpoint of the generated rest
>>> service and get the default responses (under
>>> http://localhost:8080/rest/<endpoint>).
>>>
>>> If I call http://localhost:8080/rest/swagger.json, instead of seeing
>>> the content of my swagger.json file, all I see returned is:
>>>
>>>
>>> *{"swagger":"2.0","info":{"version":"1.0.0","title":"RESTful
>>> Webservice"},"host":"localhost:8080","basePath":"/rest","schemes":["http"]}*
>>>
>>>
>>> which is what is configured in the DefaultJaxrsConfig servlet in my
>>> web.xml.
>>>
>>>
>>> If I call http://localhost:8080/rest/swagger, a file is downloaded
>>> containing the following (same content as above):
>>>
>>> *---*
>>> *swagger: "2.0"*
>>> *info:*
>>> * version: "1.0.0"*
>>> * title: "RESTful Webservice"*
>>> *host: "localhost:8080"*
>>> *basePath: "/rest"*
>>> *schemes:*
>>> *- "http"*
>>>
>>> If I try http://localhost:8080/rest/swagger/index.html, I just get a
>>> JBoss 404 error, "*JBWEB000124: The requested resource is not
>>> available.*".
>>>
>>> If I load the index.html file in my browser
>>> (src/main/webapp/swagger/index.html), I get a swagger-ui formatted page
>>> with no content from my swagger.json file.
>>>
>>> I know I must be missing something simple, but it's damned hard to find
>>> :)
>>>
>>> I would be immensely grateful for an assistance.
>>>
>>>
>>>
>>>
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Swagger" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to [email protected].
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>>
>>>
--
You received this message because you are subscribed to the Google Groups
"Swagger" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.