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.
3.1.1
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
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"
}
Related issues:
oneOf: discussion take place in #15.anyOf: #537, #559.allOf: there are also some issuesLooking forward to this feature ! I will be happy to help testing it if you need some help.
I've just run into the same problem with the Spring generator.
I've just run into the same problem with the jaxrs-resteasy (3.2.0).
I will also be happy to help testing it if you need some help.
I have the same issue, is there any plan to support "anyOf" tag?
Hi folks, I've added better support of allOf, anyOf and oneOf via #1360. Please give it a try and let us know if you've any feedback. Clearly, some works need to be done in the Java client templates to better support oneOf and anyOf.
Any news?
Any news?
Heys, can you guys please try the branch "improve-java" (https://github.com/OpenAPITools/openapi-generator/tree/improve-java) ? I've only added oneOf support but anyOf support can be easily added if you guys are ok with my approach.
Example:
git clone https://github.com/OpenAPITools/openapi-generator
git checkout improve-java
mvn clean package -DskipTests
java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generate -g java --library jersey2-experimental -i https://raw.githubusercontent.com/OpenAPITools/openapi-generator/master/modules/openapi-generator/src/test/resources/3_0/oneOf.yaml -o /tmp/oneOfTest/ --skip-validate-spec
@wing328 i don鈥檛 see the branch anymore. Did it get merged?
Please check out the latest master: java generator with the jersey2library
Most helpful comment
Any news?