swagger-api / swagger-api/swagger-codegen
[typescript-angular] docker image and jar versions mismatch. missed null check
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
All those
swaggerapi/swagger-codegen-cli:latest
swaggerapi/swagger-codegen-cli:v2.3.1
swaggerapi/swagger-codegen-cli:v2.3.0
docker images don't match
http://repo1.maven.org/maven2/io/swagger/swagger-codegen-cli/2.3.1/swagger-codegen-cli-2.3.1.jar
behaviour.
Function generated by docker image (any version):
public createItem(q?: string, body: ItemModel, observe: any = 'body', reportProgress: boolean = false): Observable<any> {
let queryParameters = new HttpParams({encoder: new CustomHttpUrlEncodingCodec()});
if (q !== undefined && q !== null) {
queryParameters = queryParameters.set('q', <any>q);
}
....
}
Function generated by swagger-codegen-cli-2.3.1.jar:
public createItem(q?: string, body: ItemModel, observe: any = 'body', reportProgress: boolean = false): Observable<any> {
let queryParameters = new HttpParams({encoder: new CustomHttpUrlEncodingCodec()});
if (q !== undefined) {
queryParameters = queryParameters.set('q', <any>q);
}
....
}
As u can see, null check is missed in generated code.
Command line used for generation
- Docker image
docker pull swaggerapi/swagger-codegen-cli
docker run --rm -v \
${PWD}/src/app/core/swagger:/local swaggerapi/swagger-codegen-cli \
generate \
-i /local/json/swagger.json \
-l typescript-angular \
-o /local/generated/out
- jar
java -jar swagger-codegen-cli-2.3.1.jar generate -i src/app/core/swagger/json/swagger.json -l typescript-angular -o src/app/core/swagger/generated/out
Steps to reproduce
- Use json file similar to this snippet
{
"swagger": "2.0",
"paths": {
"/items": {
"post": {
"summary": "Create an Item",
"description": "",
"operationId": "createItem",
"consumes": [
"application/json;charset=UTF-8"
],
"produces": [
"application/json;charset=UTF-8"
],
"parameters": [
{
"name": "q",
"in": "query",
"description": "***",
"required": false,
"type": "string"
},
{
"in": "body",
"name": "body",
"required": false,
"schema": {
"$ref": "#/definitions/CreateItemModel"
}
}
],
"responses": {
"200": {
"description": "successful operation",
"schema": {
"$ref": "#/definitions/Item"
}
}
}
}
}
}
}
- Use commands above (or similar)
- Ensure that one of those commands generates null check and the other does not
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the supplied Swagger JSON snippet and run both the Docker and swagger-codegen-cli-2.3.1.jar generation commands. Compare the generated TypeScript Angular output, especially the createItem query-parameter null check. Done means both generation paths produce matching output with the expected null check.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- angular, docker, typescript
- Domain
- developer-experience, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100