Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #9086
Closed
Open
Issue created Mar 25, 2021 by Administrator@rootContributor5 of 6 checklist items completed5/6 checklist items

[BUG] Inconsistent handling of additionalProperties

Created by: 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
Assignee
Assign to
Time tracking