forked from loafle/openapi-generator-original
Conflicts: appveyor.yml modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AbstractJavaCodegen.java modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AbstractTypeScriptClientCodegen.java modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaClientCodegen.java modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SpringCodegen.java modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/TypeScriptAngular2ClientCodegen.java modules/swagger-codegen/src/main/resources/Java/libraries/feign/pom.mustache modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/pom.mustache modules/swagger-codegen/src/main/resources/TypeScript-Fetch/api.mustache modules/swagger-codegen/src/main/resources/go/api.mustache modules/swagger-codegen/src/main/resources/objc/api-body.mustache modules/swagger-codegen/src/main/resources/objc/api-header.mustache modules/swagger-codegen/src/main/resources/typescript-angular2/configuration.mustache modules/swagger-codegen/src/main/resources/typescript-angular2/tsconfig.mustache modules/swagger-codegen/src/test/java/io/swagger/codegen/swift/SwiftModelTest.java modules/swagger-codegen/src/test/java/io/swagger/codegen/swift3/Swift3ModelTest.java modules/swagger-codegen/src/test/java/io/swagger/codegen/typescript/typescriptangular2/TypeScriptAngular2ModelTest.java samples/client/petstore-security-test/typescript-angular2/configuration.ts samples/client/petstore/go/go-petstore/docs/FakeApi.md samples/client/petstore/go/go-petstore/fake_api.go samples/client/petstore/go/go-petstore/pet_api.go samples/client/petstore/java/feign/pom.xml samples/client/petstore/java/feign/src/main/java/io/swagger/client/api/FakeApi.java samples/client/petstore/java/feign/src/main/java/io/swagger/client/api/PetApi.java samples/client/petstore/java/jersey1/src/main/java/io/swagger/client/api/FakeApi.java samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/RFC3339DateFormat.java samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/Animal.java samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/EnumTest.java samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/FormatTest.java samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/MixedPropertiesAndAdditionalPropertiesClass.java samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/FakeApi.java samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/JSON.java samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/FakeApi.java samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/PetApi.java samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/api/FakeApi.java samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/api/PetApi.java samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/api/FakeApi.java samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/api/FakeApi.java samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/api/PetApi.java samples/client/petstore/objc/core-data/SwaggerClient/Api/SWGPetApi.h samples/client/petstore/objc/core-data/SwaggerClient/Api/SWGPetApi.m samples/client/petstore/objc/core-data/SwaggerClient/Api/SWGStoreApi.h samples/client/petstore/objc/core-data/SwaggerClient/Api/SWGStoreApi.m samples/client/petstore/objc/core-data/SwaggerClient/Api/SWGUserApi.h samples/client/petstore/objc/core-data/SwaggerClient/Api/SWGUserApi.m samples/client/petstore/objc/core-data/SwaggerClient/Core/SWGApiClient.h samples/client/petstore/objc/core-data/SwaggerClient/Core/SWGConfiguration.h samples/client/petstore/objc/default/SwaggerClient/Api/SWGPetApi.h samples/client/petstore/objc/default/SwaggerClient/Api/SWGPetApi.m samples/client/petstore/objc/default/SwaggerClient/Api/SWGStoreApi.h samples/client/petstore/objc/default/SwaggerClient/Api/SWGStoreApi.m samples/client/petstore/objc/default/SwaggerClient/Api/SWGUserApi.h samples/client/petstore/objc/default/SwaggerClient/Api/SWGUserApi.m samples/client/petstore/objc/default/SwaggerClient/Core/SWGApiClient.h samples/client/petstore/objc/default/SwaggerClient/Core/SWGConfiguration.h samples/client/petstore/objc/default/SwaggerClient/Core/SWGJSONResponseSerializer.h samples/client/petstore/qt5cpp/client/SWGPetApi.h samples/client/petstore/qt5cpp/client/SWGStoreApi.h samples/client/petstore/qt5cpp/client/SWGUserApi.h samples/client/petstore/typescript-angular2/default/configuration.ts samples/client/petstore/typescript-angular2/npm/README.md samples/client/petstore/typescript-angular2/npm/configuration.ts samples/client/petstore/typescript-angular2/npm/package.json samples/client/petstore/typescript-angular2/npm/tsconfig.json samples/client/petstore/typescript-fetch/builds/default/api.ts samples/client/petstore/typescript-fetch/builds/es6-target/api.ts samples/client/petstore/typescript-fetch/builds/with-npm-version/api.ts samples/client/petstore/typescript-fetch/tests/default/test/PetApiFactory.ts samples/client/petstore/typescript-fetch/tests/default/test/StoreApiFactory.ts samples/server/petstore/jaxrs-resteasy/default/src/gen/java/io/swagger/api/PetApi.java samples/server/petstore/jaxrs-resteasy/default/src/gen/java/io/swagger/api/PetApiService.java samples/server/petstore/jaxrs-resteasy/joda/src/gen/java/io/swagger/model/User.java samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/FakeApi.java samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/FakeApiController.java samples/server/petstore/springboot/src/main/java/io/swagger/api/FakeApi.java samples/server/petstore/springboot/src/main/java/io/swagger/api/FakeApiController.java
swagger-codegen-maven-plugin
A Maven plugin to support the swagger code generation project
Usage
Add to your build->plugins
section (default phase is generate-sources
phase)
<plugin>
<groupId>io.swagger</groupId>
<artifactId>swagger-codegen-maven-plugin</artifactId>
<version>2.2.2-SNAPSHOT</version>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>src/main/resources/api.yaml</inputSpec>
<language>java</language>
<configOptions>
<sourceFolder>src/gen/java/main</sourceFolder>
</configOptions>
</configuration>
</execution>
</executions>
</plugin>
Followed by:
mvn clean compile
General Configuration parameters
inputSpec
- OpenAPI Spec file pathlanguage
- target generation languageoutput
- target output path (default is${project.build.directory}/generated-sources/swagger
)templateDirectory
- directory with mustache templatesaddCompileSourceRoot
- add the output directory to the project as a source root (true
by default)modelPackage
- the package to use for generated model objects/classesapiPackage
- the package to use for generated api objects/classesinvokerPackage
- the package to use for the generated invoker objectsmodelNamePrefix
andmodelNameSuffix
- Sets the pre- or suffix for model classes and enums.configOptions
- a map of language-specific parameters (see below)configHelp
- dumps the configuration help for the specified library (generates no sources)
Custom Generator
Specifying a custom generator is a bit different. It doesn't support the classpath:/ syntax, but it does support the fully qualified name of the package. You can also specify your custom templates, which also get pulled in. Notice the dependency on a project, in the plugin scope. That would be your generator/template jar.
<plugin>
<groupId>io.swagger</groupId>
<artifactId>swagger-codegen-maven-plugin</artifactId>
<version>${swagger-codegen-maven-plugin-version}</version>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>src/main/resources/yaml/yamlfilename.yaml</inputSpec>
<!-- language file, like e.g. JavaJaxRSCodegen shipped with swagger -->
<language>com.my.package.for.GeneratorLanguage</language>
<templateDirectory>myTemplateDir</templateDirectory>
<output>${project.build.directory}/generated-sources</output>
<apiPackage>${default.package}.handler</apiPackage>
<modelPackage>${default.package}.model</modelPackage>
<invokerPackage>${default.package}.handler</invokerPackage>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>com.my.generator</groupId>
<artifactId>customgenerator</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>
</plugin>
Sample configuration
- Please see an example configuration for using the plugin