mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-05-12 12:40:53 +00:00
* [JAVA] Fix for #18975, ensure static block of parent deser class loads * Add sample spec with type with anyOf
This commit is contained in:
parent
0d05ee35f0
commit
6b9d95be89
@ -57,7 +57,7 @@ public class {{classname}} extends AbstractOpenApiSchema{{#vendorExtensions.x-im
|
||||
|
||||
Object deserialized = null;
|
||||
{{#discriminator}}
|
||||
Class<?> cls = JSON.getClassForElement(tree, {{classname}}.class);
|
||||
Class<?> cls = JSON.getClassForElement(tree, new {{classname}}().getClass());
|
||||
if (cls != null) {
|
||||
// When the OAS schema includes a discriminator, use the discriminator value to
|
||||
// discriminate the anyOf schemas.
|
||||
|
@ -57,7 +57,7 @@ public class {{classname}} extends AbstractOpenApiSchema{{#vendorExtensions.x-im
|
||||
|
||||
Object deserialized = null;
|
||||
{{#discriminator}}
|
||||
Class<?> cls = JSON.getClassForElement(tree, {{classname}}.class);
|
||||
Class<?> cls = JSON.getClassForElement(tree, new {{classname}}().getClass());
|
||||
if (cls != null) {
|
||||
// When the OAS schema includes a discriminator, use the discriminator value to
|
||||
// discriminate the anyOf schemas.
|
||||
|
@ -54,7 +54,7 @@ public class {{classname}} extends AbstractOpenApiSchema{{#vendorExtensions.x-im
|
||||
|
||||
Object deserialized = null;
|
||||
{{#discriminator}}
|
||||
Class<?> cls = JSON.getClassForElement(tree, {{classname}}.class);
|
||||
Class<?> cls = JSON.getClassForElement(tree, new {{classname}}().getClass());
|
||||
if (cls != null) {
|
||||
// When the OAS schema includes a discriminator, use the discriminator value to
|
||||
// discriminate the anyOf schemas.
|
||||
|
47
modules/openapi-generator/src/test/resources/bugs/issue_18975.yaml
Executable file
47
modules/openapi-generator/src/test/resources/bugs/issue_18975.yaml
Executable file
@ -0,0 +1,47 @@
|
||||
openapi: 3.0.1
|
||||
info:
|
||||
title: sample issue 18975
|
||||
description: sample issue 18975
|
||||
version: "1.0"
|
||||
paths:
|
||||
/sample:
|
||||
get:
|
||||
summary: sample
|
||||
operationId: getSample
|
||||
responses:
|
||||
"200":
|
||||
description: Found vehicle.
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/DifficultType'
|
||||
components:
|
||||
schemas:
|
||||
SubA:
|
||||
required:
|
||||
- type
|
||||
type: object
|
||||
properties:
|
||||
type:
|
||||
type: string
|
||||
sim:
|
||||
type: string
|
||||
SubB:
|
||||
required:
|
||||
- type
|
||||
type: object
|
||||
properties:
|
||||
type:
|
||||
type: string
|
||||
system:
|
||||
type: string
|
||||
DifficultType:
|
||||
type: object
|
||||
discriminator:
|
||||
propertyName: type
|
||||
mapping:
|
||||
"typeA": '#/components/schemas/SubA'
|
||||
"typeB": '#/components/schemas/SubB'
|
||||
anyOf:
|
||||
- $ref: '#/components/schemas/SubA'
|
||||
- $ref: '#/components/schemas/SubB'
|
Loading…
x
Reference in New Issue
Block a user