OpenAPITools / OpenAPITools/openapi-generator
[BUG] Conversion from v2 to v3 incorrectly changes additionalProperties: {} into additionalProperties: type: object
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Bug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- Have you validated the input using an OpenAPI validator (example)?
- Have you tested with the latest master to confirm the issue still exists?
- Have you searched for related issues/PRs?
- What's the actual output vs expected output?
- [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
I have an OpenAPI v2 yaml that is being converted to v3 by openapi-generator-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.
Basically, it should be treating additionalProperties: {} just like it treats additionalProperties: true, but instead it converts additionalProperties: {} incorrectly.
openapi-generator version
v7.8.0
OpenAPI declaration file content or url
My openapi v2 yaml includes:
protobufAny:
type: object
properties:
'@type':
type: string
additionalProperties: {}
Generation Details
openapi-generator generate -i ./awesome.swagger.yaml -g openapi-yaml -o ./openapiv3
This is converted by openapi-generator into this yaml:
components:
schemas:
protobufAny:
additionalProperties:
type: object
properties:
'@type':
type: string
type: object
Instead it should be generating this following:
components:
schemas:
protobufAny:
additionalProperties: true
properties:
'@type':
type: string
type: object
Steps to reproduce
openapi-generator generate -i ./awesome.swagger.yaml -g openapi-yaml -o ./openapiv3
Using this openapi v2 yaml
Suggest a fix
This should be generated instead:
components:
schemas:
protobufAny:
additionalProperties: true
properties:
'@type':
type: string
type: object
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 by reproducing the issue with the provided openapi-generator generate command and the linked OpenAPI v2 YAML. Compare how additionalProperties: {} and additionalProperties: true are converted in the generated OpenAPI v3 YAML. Done means the empty object is emitted as additionalProperties: true without changing other schema fields.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100