swagger-api / swagger-api/swagger-codegen
Conversion from v2 to v3 incorrectly changes additionalProperties: {} into additionalProperties: type: object
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
I have an OpenAPI v2 yaml that is being converted to v3 by swagger-codegen-cli, and it ends up changing the behavior of my models from allowing any freeform additional properties of any type, to only allowing properties of type object.
Swagger-codegen version
3.0.61
Swagger declaration file content or url
My openapi v2 yaml includes:
protobufAny:
type: object
properties:
'@type':
type: string
additionalProperties: {}
This is converted by swagger-codegen-api into this yaml:
protobufAny:
type: object
properties:
'@type':
type: string
additionalProperties:
type: object
Command line used for generation
swagger-codegen-cli generate -i ./openapiv2/gen/awesome.swagger.yaml -l openapi-yaml -o ./openapiv3/gen/
Steps to reproduce
See above
Related issues/PRs
N/A
Suggest a fix/enhancement
This v2 yaml should convert to additionalProperties: {} or additionalProperties: true
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
Run the supplied swagger-codegen-cli command with the linked OpenAPI v2 YAML and inspect the conversion path for an empty additionalProperties value. Done means the generated OpenAPI v3 YAML preserves it as additionalProperties: {} or additionalProperties: true rather than assigning type: object.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- openapi
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100