Skip to content

[BUG] Inconsistent handling of additionalProperties #9086

@GabrielCastro

Description

@GabrielCastro

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

There is inconsistent handling of the additionalProperties: false keyword for swagger v2.0 schemas depending on where in the document a schema is defined.

Given an object schema of type: object, additionalProperties: false

When the schema is defined in #/definitions/some_schema everything works as expected.

When the schema is defined in #/paths/_some_path_/_any_method_/responses/200/schema directly, all object is treated as a { type: object, additionalProperties: { type: object } } losing all properties in the generated code.
The generated code results as a Map<String, Object> instead of a generated class.

openapi-generator version

Tested in 5.0.0 and master (6.0.0-20210320.175023-11)

https://gist.github.com/GabrielCastro/dc4c5555d720d359b77c720d35e85732

Generation Details

applies to all code generators, including openapi-yaml

Steps to reproduce

get the schema from https://gist.github.com/GabrielCastro/dc4c5555d720d359b77c720d35e85732#file-buggy_api-yaml

generate using openapi-generator -i buggy_api.yaml -g openapi-yaml -o ./out/2-to3

The output file will have a mis-generated response where the expected output is a properly typed object

Actual output
https://gist.github.com/GabrielCastro/dc4c5555d720d359b77c720d35e85732#file-actual-ouput-yaml-L15
Expected output
https://gist.github.com/GabrielCastro/dc4c5555d720d359b77c720d35e85732#file-expected-output-yaml-L17

Related issues/PRs
Suggest a fix

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions