... | @@ -23,7 +23,7 @@ For major releases, it should probably take more than 6 months. |
... | @@ -23,7 +23,7 @@ For major releases, it should probably take more than 6 months. |
|
### How to debug OpenAPI Generator?
|
|
### How to debug OpenAPI Generator?
|
|
|
|
|
|
You can leverage the following debug flags when generating the libraries:
|
|
You can leverage the following debug flags when generating the libraries:
|
|
- [debugSwagger] prints the swagger specification as interpreted by the codegen
|
|
- [debugOpenAPI] prints the OpenAPI specification as interpreted by the codegen
|
|
- [debugModels] prints models passed to the template engine
|
|
- [debugModels] prints models passed to the template engine
|
|
- [debugOperations] prints operations passed to the template engine
|
|
- [debugOperations] prints operations passed to the template engine
|
|
- [debugSupportingFiles] prints additional data passed to the template engine
|
|
- [debugSupportingFiles] prints additional data passed to the template engine
|
... | @@ -32,7 +32,7 @@ Here is an example using `debugModels`: |
... | @@ -32,7 +32,7 @@ Here is an example using `debugModels`: |
|
```
|
|
```
|
|
mvn clean package
|
|
mvn clean package
|
|
java -DdebugModels=true -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generate \
|
|
java -DdebugModels=true -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generate \
|
|
-i http://petstore.swagger.io/v2/swagger.json \
|
|
-i https://raw.githubusercontent.com/OpenAPITools/openapi-generator/master/modules/openapi-generator/src/test/resources/2_0/petstore.json \
|
|
-l ruby -o /var/tmp/ruby/
|
|
-l ruby -o /var/tmp/ruby/
|
|
```
|
|
```
|
|
### How do "tags" affect the generated code?
|
|
### How do "tags" affect the generated code?
|
... | @@ -41,21 +41,13 @@ java -DdebugModels=true -jar modules/openapi-generator-cli/target/openapi-genera |
... | @@ -41,21 +41,13 @@ java -DdebugModels=true -jar modules/openapi-generator-cli/target/openapi-genera |
|
|
|
|
|
Ref: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#tagObject
|
|
Ref: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#tagObject
|
|
|
|
|
|
### How to import Java objects that are not defined as model in the OpenAPI/Swagger spec?
|
|
### How to import Java objects that are not defined as a model in the OpenAPI v2 or v3 spec?
|
|
|
|
|
|
Please refer to https://github.com/openapitools/openapi-generator#bringing-your-own-models
|
|
Please refer to https://github.com/openapitools/openapi-generator#bringing-your-own-models
|
|
|
|
|
|
<!--
|
|
|
|
### What does https://editor.swagger.io leverage OpenAPI Generator for code generation?
|
|
|
|
|
|
|
|
https://editor.swagger.io submits HTTP request to https://generator.swagger.io (part of OpenAPI Generator project) to generate code.
|
|
|
|
|
|
|
|
https://generator.swagger.io usually runs the latest [stable version](https://github.com/openapitools/openapi-generator/releases/latest) (not latest master). To use the latest master of OpenAPI Generator, you will have to clone the project and [build the JAR locally](https://github.com/openapitools/openapi-generator#getting-started) or use [docker](https://github.com/openapitools/openapi-generator#public-pre-built-docker-images).
|
|
|
|
-->
|
|
|
|
|
|
|
|
### Is there a way to disable certificate verification?
|
|
### Is there a way to disable certificate verification?
|
|
|
|
|
|
Please add `-Dio.swagger.parser.util.RemoteUrl.trustAll=true` when generating the code.
|
|
Please add `-Dio.swagger.v3.parser.util.RemoteUrl.trustAll=true` when generating the code.
|
|
|
|
|
|
### How to skip certain files during code generation?
|
|
### How to skip certain files during code generation?
|
|
|
|
|
... | @@ -68,7 +60,7 @@ For example, to skip `git_push.sh`, one can create a file named `.openapi-genera |
... | @@ -68,7 +60,7 @@ For example, to skip `git_push.sh`, one can create a file named `.openapi-genera |
|
You can use the `-t` option with the customized templates. Here is an example adding header/footer to Ruby templates.
|
|
You can use the `-t` option with the customized templates. Here is an example adding header/footer to Ruby templates.
|
|
|
|
|
|
1. git clone https://github.com/openapitools/openapi-generator
|
|
1. git clone https://github.com/openapitools/openapi-generator
|
|
2. cd swagger-codegen
|
|
2. cd openapi-generator
|
|
3. mvn clean package
|
|
3. mvn clean package
|
|
4. cp -R modules/openapi-generator/src/main/resources/ruby /var/tmp/ ## copy all Ruby templates to /var/tmp/. You can also selectively copy only the templates (e.g. api.mustache) you want to customize
|
|
4. cp -R modules/openapi-generator/src/main/resources/ruby /var/tmp/ ## copy all Ruby templates to /var/tmp/. You can also selectively copy only the templates (e.g. api.mustache) you want to customize
|
|
5. Edit /var/tmp/ruby/api.mustache to add the footer/header
|
|
5. Edit /var/tmp/ruby/api.mustache to add the footer/header
|
... | @@ -110,7 +102,7 @@ Please refer to http://rypress.com/tutorials/git/rebasing, or follow the steps b |
... | @@ -110,7 +102,7 @@ Please refer to http://rypress.com/tutorials/git/rebasing, or follow the steps b |
|
5. Resolve merge conflicts, if any, and run "git commit -a"
|
|
5. Resolve merge conflicts, if any, and run "git commit -a"
|
|
6. Rebase done (you may need to add --force when doing `git push`)
|
|
6. Rebase done (you may need to add --force when doing `git push`)
|
|
|
|
|
|
(To setup `upstream` pointing to the official repo, please run `git remote add upstream https://github.com/swagger-api/swagger-samples.git`)
|
|
(To setup `upstream` pointing to the official repo, please run `git remote add upstream https://github.com/openapitools/openapi-generator.git`)
|
|
|
|
|
|
### How can I update commits that are not linked to my Github account?
|
|
### How can I update commits that are not linked to my Github account?
|
|
|
|
|
... | @@ -124,82 +116,17 @@ Yes, http://www.alexkras.com/19-git-tips-for-everyday-use/ |
... | @@ -124,82 +116,17 @@ Yes, http://www.alexkras.com/19-git-tips-for-everyday-use/ |
|
|
|
|
|
Visit https://github.com/openapitools/openapi-generator and then click on the "Fork" button in the upper right corner. Then in your local machine, run the following (assuming your github ID is "your_user_id")
|
|
Visit https://github.com/openapitools/openapi-generator and then click on the "Fork" button in the upper right corner. Then in your local machine, run the following (assuming your github ID is "your_user_id")
|
|
|
|
|
|
1) git clone https://github.com/your_user_id/swagger-codegen.git
|
|
1) git clone https://github.com/your_user_id/openapi-generator.git
|
|
2) cd swagger-codegen
|
|
2) cd openapi-generator
|
|
3) git checkout -b fix_issue9999
|
|
3) git checkout -b fix_issue9999
|
|
4) make changes
|
|
4) make changes
|
|
5) git commit -a (you may need to use `git add filename` to add new files)
|
|
5) git commit -a (you may need to use `git add filename` to add new files)
|
|
6) git push origin fix_issue9999
|
|
6) git push origin fix_issue9999
|
|
7) Visit https://github.com/openapitools/openapi-generator in your browser and click on the button to file a new PR based on fix_issue9999
|
|
7) Visit https://github.com/openapitools/openapi-generator in your browser and click on the button to file a new PR based on fix_issue9999
|
|
|
|
|
|
<!--
|
|
|
|
## Generator Service
|
|
|
|
https://generator.swagger.io/
|
|
|
|
|
|
|
|
The API is split into two sections: client and server. The endpoints under client are meant for generating code to consume an API. The endpoints under server are meant for generating code to run the API itself (server stubs etc).
|
|
|
|
|
|
|
|
Each section has 4 endpoints
|
|
|
|
* Get a list of languages/frameworks that you can generate code for
|
|
|
|
* Get options schema for a language/framework (where do these options go? options in GeneratorInput?)
|
|
|
|
* Post GeneratorInput to generate code to a zip file and get back link to file
|
|
|
|
* Get zip file (download)
|
|
|
|
|
|
|
|
Example node script to generate typescript angular client from swagger.yaml. Note that we use http. Request cannot verify the first certificate if using https (at the time of writing this)
|
|
|
|
```javascript
|
|
|
|
var fs = require('fs');
|
|
|
|
var path = require('path');
|
|
|
|
var jsYaml = require('js-yaml');
|
|
|
|
var request = require('request');
|
|
|
|
var unzip = require('unzip2');
|
|
|
|
|
|
|
|
var codeGenEndpoint = 'http://generator.swagger.io/api/gen/clients';
|
|
|
|
var language = 'typescript-angular';
|
|
|
|
|
|
|
|
fs.readFile(path.resolve('swagger.yaml'), 'utf8', function (error, yaml) {
|
|
|
|
if (error) {
|
|
|
|
throw error;
|
|
|
|
}
|
|
|
|
|
|
|
|
var swaggerObj = jsYaml.load(yaml);
|
|
|
|
|
|
|
|
var postBody = {
|
|
|
|
spec: swaggerObj,
|
|
|
|
options: {
|
|
|
|
modelPropertyNaming: 'camelCase',
|
|
|
|
apiPackage: 'api.clients.settings',
|
|
|
|
modelPackage: 'api.clients.settings'
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
request.post({
|
|
|
|
url: codeGenEndpoint + '/' + language,
|
|
|
|
body: JSON.stringify(postBody),
|
|
|
|
headers: {
|
|
|
|
'Content-Type': 'application/json'
|
|
|
|
}
|
|
|
|
}, function(error, response, body){
|
|
|
|
if (error) {
|
|
|
|
throw error;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (response.statusCode !== 200) {
|
|
|
|
throw new Error('Response code was not 200. ' + body)
|
|
|
|
}
|
|
|
|
|
|
|
|
var responseObj = JSON.parse(body);
|
|
|
|
|
|
|
|
request({
|
|
|
|
url: responseObj.link,
|
|
|
|
encoding: null
|
|
|
|
}).pipe(unzip.Extract({ path: 'src/client/js/codegen/settingsApi'}));
|
|
|
|
});
|
|
|
|
});
|
|
|
|
```
|
|
|
|
-->
|
|
|
|
|
|
|
|
## Java
|
|
## Java
|
|
|
|
|
|
### Using Java API client to make request results in SSL errors due to invalid certificate. Is there a way to bypass that?
|
|
### Using Java API client to make request results in SSL errors due to an invalid certificate. Is there a way to bypass that?
|
|
|
|
|
|
Yes, please refer to http://stackoverflow.com/a/6055903/677735
|
|
Yes, please refer to http://stackoverflow.com/a/6055903/677735
|
|
|
|
|
... | @@ -213,7 +140,7 @@ Yes, please refer to http://stackoverflow.com/a/6055903/677735 |
... | @@ -213,7 +140,7 @@ Yes, please refer to http://stackoverflow.com/a/6055903/677735 |
|
```
|
|
```
|
|
mvn clean package
|
|
mvn clean package
|
|
java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generate \
|
|
java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generate \
|
|
-i http://petstore.swagger.io/v2/swagger.json \
|
|
-i https://raw.githubusercontent.com/OpenAPITools/openapi-generator/master/modules/openapi-generator/src/test/resources/2_0/petstore.json \
|
|
-l java --library=okhttp-gson \
|
|
-l java --library=okhttp-gson \
|
|
-D hideGenerationTimestamp=true \
|
|
-D hideGenerationTimestamp=true \
|
|
-o /var/tmp/java/okhttp-gson/
|
|
-o /var/tmp/java/okhttp-gson/
|
... | @@ -229,7 +156,7 @@ To generate the Android SDK with [`volley`](https://github.com/mcxiaoke/android- |
... | @@ -229,7 +156,7 @@ To generate the Android SDK with [`volley`](https://github.com/mcxiaoke/android- |
|
```
|
|
```
|
|
mvn clean package
|
|
mvn clean package
|
|
java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generate \
|
|
java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generate \
|
|
-i http://petstore.swagger.io/v2/swagger.json \
|
|
-i https://raw.githubusercontent.com/OpenAPITools/openapi-generator/master/modules/openapi-generator/src/test/resources/2_0/petstore.json \
|
|
-l android --library=volley \
|
|
-l android --library=volley \
|
|
-o /var/tmp/android/volley/
|
|
-o /var/tmp/android/volley/
|
|
```
|
|
```
|
... | @@ -248,7 +175,7 @@ The warning has no impact to the build process so you should be able to build th |
... | @@ -248,7 +175,7 @@ The warning has no impact to the build process so you should be able to build th |
|
Here are the steps:
|
|
Here are the steps:
|
|
```
|
|
```
|
|
git clone https://github.com/openapitools/openapi-generator.git
|
|
git clone https://github.com/openapitools/openapi-generator.git
|
|
cd openapi-generator/samples/client/petstore/objc/default/SwaggerClientTests
|
|
cd openapi-generator/samples/client/petstore/objc/default/OpenAPIClientTests
|
|
mvn integration-test
|
|
mvn integration-test
|
|
```
|
|
```
|
|
|
|
|
... | @@ -261,13 +188,13 @@ Besides `default` (folder) ObjC API client, there's also `core-data` for another |
... | @@ -261,13 +188,13 @@ Besides `default` (folder) ObjC API client, there's also `core-data` for another |
|
Here are the steps:
|
|
Here are the steps:
|
|
```
|
|
```
|
|
git clone https://github.com/openapitools/openapi-generator.git
|
|
git clone https://github.com/openapitools/openapi-generator.git
|
|
cd openapi-generator/samples/client/petstore/swift/default/SwaggerClientTests
|
|
cd openapi-generator/samples/client/petstore/swift/default/OpenAPIClientTests
|
|
mvn integration-test
|
|
mvn integration-test
|
|
```
|
|
```
|
|
Besides `default` (folder), there's another folder `promisekit` for Swift API client with [PromiseKit support](https://github.com/mxcl/PromiseKit)
|
|
Besides `default` (folder), there's another folder `promisekit` for Swift API client with [PromiseKit support](https://github.com/mxcl/PromiseKit)
|
|
```
|
|
```
|
|
git clone https://github.com/openapitools/openapi-generator.git
|
|
git clone https://github.com/openapitools/openapi-generator.git
|
|
cd openapi-generator/samples/client/petstore/swift/promisekit/SwaggerClientTests
|
|
cd openapi-generator/samples/client/petstore/swift/promisekit/OpenAPIClientTests
|
|
mvn integration-test
|
|
mvn integration-test
|
|
```
|
|
```
|
|
|
|
|
... | @@ -275,8 +202,6 @@ mvn integration-test |
... | @@ -275,8 +202,6 @@ mvn integration-test |
|
|
|
|
|
No, please use `swift3` or `swift4` generator instead as we want to focus on Swift 3.x, 4.x.
|
|
No, please use `swift3` or `swift4` generator instead as we want to focus on Swift 3.x, 4.x.
|
|
|
|
|
|
Ref: https://github.com/swagger-api/swagger-codegen/issues/4098#issuecomment-328142793
|
|
|
|
|
|
|
|
## TypeScript
|
|
## TypeScript
|
|
|
|
|
|
### The JSON response failed to deserialize properly into the object due to change in variable naming (snake_case to camelCase). Is there any way to keep the original naming?
|
|
### The JSON response failed to deserialize properly into the object due to change in variable naming (snake_case to camelCase). Is there any way to keep the original naming?
|
... | | ... | |