question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Java] Add proper support for allOf anyOf oneOf

See original GitHub issue
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"
}

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:15
  • Comments:15 (7 by maintainers)

github_iconTop GitHub Comments

12reactions
fboucquezcommented, Jul 29, 2019

Any news?

7reactions
tr7zwcommented, Nov 9, 2021

It’s been 3 years now, and from what I can tell this is not supported by any client currently(even removed the(incomplete) feature from jersey2), so any hope that this will ever be supported? I see the Hacktoberfest label got added, but what happend to the ~4 different implementations that where in pr’s/in the 4.3 releases?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Support for oneOf, anyOf and allOf - Liferay Help Center
Specifically, it added support for allOf, anyOf, and oneOf, ... This OpenAPI syntax generates the following Java code inside the EntityC class:
Read more >
validation - JSON Schema: Using anyOf, oneOf, allOf within ...
My assumption is that this will not work because the passing schema(s) in oneOf|anyOf|allOf of additionalProperties must apply to ALL keys ...
Read more >
oneOf, anyOf, allOf, not - Swagger
oneOf – validates the value against exactly one of the subschemas; allOf ... The example above shows how to validate the request body...
Read more >
Schema in a response allows additional properties
Remediation · allOf must always have additionalProperties set to true , in both root schema and subschemas. · anyOf and oneOf for primitives...
Read more >
Language Guide (proto3) | Protocol Buffers - Google Developers
This guide describes how to use the protocol buffer language to ... A scalar message field can have one of the following types...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found