Skip to content

[BUG] [Java] Empty object property not working correctly #6400

@spacether

Description

@spacether

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • What's the version of OpenAPI Generator used?
  • Have you search for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Bounty to sponsor the fix (example)
Description

When defining a schema that looks like this:

components:
  SomeObject:
    type: object
    properties:
      empty_map:
        type: object
        additionalProperties: false

We would expect to only accept this payload:
{"empty_map": {}}
But our code ends up accepting javascript objects with any values and any number of key value pairs.

@sebastien-rosset

openapi-generator version

Master branch

OpenAPI declaration file content or url

See the above example

Command line used for generation

any generator
this came up in python-experimental in #6290

Steps to reproduce

Generate a model for the above schema and check the validations in that model

Related issues/PRs
Suggest a fix

When this condition is seen (property schema of type object with no properties and additionalProperties: False) in Java we need to set the maxItems for this property to 0.

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