swagger-api / swagger-api/swagger-codegen
[Language Agnostic] Regression between versions 2.3.1 and 2.4.5 finding some response type definitions
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
I can't tell which version specifically caused this regression because my project doesn't build on any versions in between 2.3.1 and 2.4.5.
Here is the spec where this occurs:
{
"info": {
},
"paths": {
"/user/email/v1": {
"post": {
"description": "email address",
"operationId": "post_user_email_v1",
"parameters": [
{
"description": "The future business user's email address. AdditionalProperties are allowed in order to accept utm_params",
"in": "body",
"name": "body",
"required": true,
"schema": {
"additionalProperties": true,
"properties": {
"enc_email_addr": {
"description": "An email address",
"type": "string"
},
"utm_campaign": {
"description": "(Optional) The campaign of the request, provided by the deep link URL",
"type": "string"
}
},
"required": [
"enc_email_addr"
],
"type": "object",
"x-model": "PostUserEmailV1_RequestData"
}
}
],
"responses": {
"200": {
"description": "A successful request will return a email address",
"examples": {
"application/json": {
"email": "testuser@example.com"
}
},
"schema": {
"additionalProperties": false,
"properties": {
"email": {
"description": "Email address",
"type": "string"
}
},
"required": [
"email"
],
"type": "object",
"x-model": "PostUserEmailV1_ResponseData"
}
},
"default": {
"description": "Error response",
"schema": {
"$ref": "#/definitions/ErrorResponse"
}
}
}
}
}
},
"produces": [
"application/json"
],
"schemes": [
"http"
],
"swagger": "2.0"
}
With the above example, the following are the contents of allDefinitions in fromModel(name: String, model: Model, allDefinitions: MutableMap<String, Model>?): CodegenModel
2.3.1:
The request parameters model
The response parameters model
2.4.5:
The request parameters model
Removing "additionalProperties": false, from the response schema "solves" the problem. This of course isn't a real solution, but it gets the response model included in allDefinitions.
Swagger-codegen version
2.3.1 is the last working version. This bug still exists in 3.0.14. It was introduced some time between 2.3.1 and 2.4.5. It is a regression as far as I can tell.
Swagger declaration file content or url
See json above
Command line used for generation
We're using custom tooling on top of swagger-codegen. I can try and figure out what command ends up getting used if it would be helpful though.
Steps to reproduce
See above
Related issues/PRs
Similar issue from May. My issue adds the additional information that this behavior is a regression and which versions it may have been introduced in.
https://github.com/swagger-api/swagger-codegen/issues/9262
Suggest a fix/enhancement
See linked issue.
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 at fromModel(name: String, model: Model, allDefinitions: MutableMap<String, Model>?) and reproduce the regression with the supplied Swagger 2.0 specification across versions 2.3.1, 2.4.5, and 3.0.14. Done means the response model is included in allDefinitions without removing additionalProperties: false.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- openapi
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100