swagger-api/swagger-codegen

The files and directory structures output into generated-sources by swagger-codegen-maven-plugin are unusable

Aperta

#1737 aperta il 17 dic 2015

 (17 commenti) (14 reazioni) (0 assegnatari)HTML (5474 fork)batch import
General: SuggestionSwagger Codegen Maven Pluginhelp wanted

Metriche repository

Star
 (12.701 stelle)
Metriche merge PR
 (Metriche PR in attesa)

Descrizione

Similar code generator plugins for SOAP, Thrift, WADL, etc. output the sources directly into /target/generated-sources/wsimport/. The contents of this directory is source code and package directories only; nothing else.

When swagger-codegen-maven-plugin is executed, it outputs a complete Maven project directory structure and build files into /target/generated-sources/swagger/. When Maven gets to the compile phase, the source files are not found and the build fails.

What gets generated by swagger-codegen-maven-plugin:

\---target
    +---generated-sources
    |   \---swagger
    |       |   build.gradle
    |       |   gradle.properties
    |       |   pom.xml
    |       |   README.md
    |       |   settings.gradle
    |       |
    |       \---src
    |           \---main
    |               |   AndroidManifest.xml
    |               |
    |               \---java
    |                   \---io
    |                       \---swagger
    |                           \---client
    |                               |   ApiClient.java
    |                               |   ApiException.java
    |                               |   Configuration.java
    |                               |   JSON.java
    |                               |   Pair.java
    |                               |   StringUtil.java
    |                               |
    |                               +---api
    |                               |       PetApi.java
    |                               |       StoreApi.java
    |                               |       UserApi.java
    |                               |
    |                               +---auth
    |                               |       ApiKeyAuth.java
    |                               |       Authentication.java
    |                               |       HttpBasicAuth.java
    |                               |       OAuth.java
    |                               |       OAuthFlow.java
    |                               |
    |                               \---model
    |                                       ApiResponse.java
    |                                       Category.java
    |                                       Order.java
    |                                       Pet.java
    |                                       Tag.java
    |                                       User.java

What it should be generating to be usable:

\---target
    +---generated-sources
    |   \---swagger
    |       \---io
    |           \---swagger
    |               \---client
    |                   |   ApiClient.java
    |                   |   ApiException.java
    |                   |   Configuration.java
    |                   |   JSON.java
    |                   |   Pair.java
    |                   |   StringUtil.java
    |                   |
    |                   +---api
    |                   |       PetApi.java
    |                   |       StoreApi.java
    |                   |       UserApi.java
    |                   |
    |                   +---auth
    |                   |       ApiKeyAuth.java
    |                   |       Authentication.java
    |                   |       HttpBasicAuth.java
    |                   |       OAuth.java
    |                   |       OAuthFlow.java
    |                   |
    |                   \---model
    |                           ApiResponse.java
    |                           Category.java
    |                           Order.java
    |                           Pet.java
    |                           Tag.java
    |                           User.java

When I move and delete files by hand I can get it to compile, package and run successfully.

IMO the swagger-codegen-maven-plugin is unusable in its current form.

Guida contributor