Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Conversion from v2 to v3 incorrectly changes additionalProperties: {} into additionalProperties: type: object #19596

Open
5 of 6 tasks
veqryn opened this issue Sep 16, 2024 · 0 comments

Comments

@veqryn
Copy link

veqryn commented Sep 16, 2024

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
@veqryn veqryn changed the title [BUG] Description [BUG] Conversion from v2 to v3 incorrectly changes additionalProperties: {} into additionalProperties: type: object Sep 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant