Skip to content

[Java] Add proper support for allOf anyOf oneOf #634

Open
@MarvGilb

Description

@MarvGilb
Description

In the openApiSpec it is possible to define a schema with properties, where one property can be defined directly or be using oneOf anyOf or allOf and passing the some provided Schemas.

Currently only allOf is considered and only the first of these schemas is taken (allOf requires all of them!). The other two delimiter are not even considered.

The following example makes it only possible to set the CustomProperties.

openapi-generator version

3.1.1

OpenAPI declaration file content or url

Sample Snippet.:

info:
  title: test
  version: 1.0.0
paths:
  /test:
    get:
      responses:
        '200':
          description: All good
          content:
            '*/*':
              schema:
                $ref: '#/components/schemas/ObjectWithProps'
      operationId: get
      summary: Get object with properties.
components:
  schemas:
    ObjectWithProps:
      properties:
        properties:
          allOf:
           - $ref: '#/components/schemas/CustomProperties'
           - $ref: '#/components/schemas/Properties'
      description: An object with difined and undifined keys.
    CustomProperties:
      description: The custom properties key.
      type: object
      properties:
        'someDefinedKey':
          type: object
          additionalProperties:
            type: object
    Properties:
      description: The wildcard properties key.
      type: object
      additionalProperties:
        type: object
openapi: 3.0.0
Steps to reproduce
java -jar ${PathToOpenApiGeneratorJAR3.1.1} generate \
 -i /path/swagger3.yaml \
 -o /path/swagger3-client \
 --api-package "com.123" \
 --model-package "com.123" \
 --group-id "com.123" \
 --artifact-id "123" \
 --artifact-version "SNAPSHOT" \
 -c ./java-options.json \
 -g java

JavaOptions:

{
  "java8": true,
  "dateLibrary": "java8"
}

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