swagger-api / swagger-codegen

swagger-codegen contains a template-driven engine to generate documentation, API clients and server stubs in different languages by parsing your OpenAPI / Swagger definition.
http://swagger.io
Apache License 2.0
17.06k stars 6.03k forks source link

Conversion from v2 to v3 incorrectly changes additionalProperties: {} into additionalProperties: type: object #12468

Open veqryn opened 2 months ago

veqryn commented 2 months ago
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

ponelat commented 2 months ago

Thanks for the report @veqryn ! This is a low priority issue, and may not get attention from the core team any time soon, but a PR would be welcomed :)