Skip to content

Schema.getAdditionalProperties(): return something better as Object? #257

Closed
@jmini

Description

@jmini

Per spec: additionalProperties in a Schema object can be an Object or a Boolean.
See OAI/OpenAPI-Specification#668 (comment)

In the code, Object is returned:
https://github.com/eclipse/microprofile-open-api/blob/c2a26360d460bfe07b30c83ba4fe6f9cc73543c6/api/src/main/java/org/eclipse/microprofile/openapi/models/media/Schema.java#L641

This is not really user-friendly because the user needs to know that this Object can be a Schema or a Boolean and write code with instanceOf to reflect this.


Kaizen Model has 2 getters for this:

  • Boolean getAdditionalProperties()
  • Schema getAdditionalPropertiesSchema()

I do not like this either, but it is better in a sense that no instanceOf is needed.

kaizen-parser Schema.java


What is the typical java way of telling Schama or Boolean (a sort of Union Types)?
A new Interface AdditionalProperties with 2 getters returning an optional:

  • Optional<Schema> getAsSchema()
  • Optional<Boolean> getAsBoolean()

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions