diff --git a/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/converters/PolymorphicModelConverter.java b/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/converters/PolymorphicModelConverter.java index eb9e04adb..e243f7e1a 100644 --- a/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/converters/PolymorphicModelConverter.java +++ b/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/converters/PolymorphicModelConverter.java @@ -27,9 +27,9 @@ import java.lang.reflect.Modifier; import java.util.ArrayList; import java.util.Collection; +import java.util.Collections; import java.util.Iterator; import java.util.List; -import java.util.stream.Collectors; import com.fasterxml.jackson.databind.JavaType; import io.swagger.v3.core.converter.AnnotatedType; @@ -43,6 +43,7 @@ /** * The type Polymorphic model converter. + * * @author bnasslahsen */ public class PolymorphicModelConverter implements ModelConverter { @@ -52,6 +53,17 @@ public class PolymorphicModelConverter implements ModelConverter { */ private final ObjectMapperProvider springDocObjectMapper; + /** + * The constant PARENT_TYPES_TO_IGNORE. + */ + private static final List PARENT_TYPES_TO_IGNORE = Collections.synchronizedList(new ArrayList<>()); + + static { + PARENT_TYPES_TO_IGNORE.add("JsonSchema"); + PARENT_TYPES_TO_IGNORE.add("Pageable"); + PARENT_TYPES_TO_IGNORE.add("EntityModel"); + } + /** * Instantiates a new Polymorphic model converter. * @@ -61,12 +73,21 @@ public PolymorphicModelConverter(ObjectMapperProvider springDocObjectMapper) { this.springDocObjectMapper = springDocObjectMapper; } - private static Schema getResolvedSchema(JavaType javaType, Schema resolvedSchema) { + /** + * Add parent type. + * + * @param parentTypes the parent types + */ + public static void addParentType(String... parentTypes) { + PARENT_TYPES_TO_IGNORE.addAll(List.of(parentTypes)); + } + + private Schema getResolvedSchema(JavaType javaType, Schema resolvedSchema) { if (resolvedSchema instanceof ObjectSchema && resolvedSchema.getProperties() != null) { - if (resolvedSchema.getProperties().containsKey(javaType.getRawClass().getName())){ + if (resolvedSchema.getProperties().containsKey(javaType.getRawClass().getName())) { resolvedSchema = resolvedSchema.getProperties().get(javaType.getRawClass().getName()); } - else if (resolvedSchema.getProperties().containsKey(javaType.getRawClass().getSimpleName())){ + else if (resolvedSchema.getProperties().containsKey(javaType.getRawClass().getSimpleName())) { resolvedSchema = resolvedSchema.getProperties().get(javaType.getRawClass().getSimpleName()); } } @@ -78,6 +99,9 @@ public Schema resolve(AnnotatedType type, ModelConverterContext context, Iterato JavaType javaType = springDocObjectMapper.jsonMapper().constructType(type.getType()); if (javaType != null) { if (chain.hasNext()) { + if (!type.isResolveAsRef() && type.getParent() != null + && PARENT_TYPES_TO_IGNORE.stream().noneMatch(ignore -> type.getParent().getName().startsWith(ignore))) + type.resolveAsRef(true); Schema resolvedSchema = chain.next().resolve(type, context, chain); resolvedSchema = getResolvedSchema(javaType, resolvedSchema); if (resolvedSchema == null || resolvedSchema.get$ref() == null) @@ -91,8 +115,8 @@ public Schema resolve(AnnotatedType type, ModelConverterContext context, Iterato /** * Compose polymorphic schema. * - * @param type the type - * @param schema the schema + * @param type the type + * @param schema the schema * @param schemas the schemas * @return the schema */ @@ -111,7 +135,7 @@ private Schema composePolymorphicSchema(AnnotatedType type, Schema schema, Colle /** * Find composed schemas recursively. * - * @param ref the reference of the schema + * @param ref the reference of the schema * @param schemas the collection of schemas to search in * @return the list of composed schemas */ @@ -133,6 +157,7 @@ private List findComposedSchemas(String ref, Collection schemas) return resultSchemas; } + /** * Is concrete class boolean. * diff --git a/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/utils/SpringDocUtils.java b/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/utils/SpringDocUtils.java index 09175e6e4..f1023e3c6 100644 --- a/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/utils/SpringDocUtils.java +++ b/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/utils/SpringDocUtils.java @@ -32,6 +32,7 @@ import org.springdoc.api.AbstractOpenApiResource; import org.springdoc.core.converters.AdditionalModelsConverter; import org.springdoc.core.converters.ConverterUtils; +import org.springdoc.core.converters.PolymorphicModelConverter; import org.springdoc.core.converters.SchemaPropertyDeprecatingConverter; import org.springdoc.core.extractor.MethodParameterPojoExtractor; import org.springdoc.core.service.AbstractRequestService; @@ -388,5 +389,16 @@ public static boolean isValidPath(String path) { return true; return false; } + + /** + * Add parent type spring doc utils. + * + * @param parentTypes the parent types + * @return the spring doc utils + */ + public SpringDocUtils addParentType(String ...parentTypes) { + PolymorphicModelConverter.addParentType(parentTypes); + return this; + } } diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v30/app223/ARestController.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v30/app223/ARestController.java new file mode 100644 index 000000000..8c672eb38 --- /dev/null +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v30/app223/ARestController.java @@ -0,0 +1,23 @@ +package test.org.springdoc.api.v30.app223; + + +import test.org.springdoc.api.v30.app223.apiobjects.AbstractChild; +import test.org.springdoc.api.v30.app223.apiobjects.AbstractParent; +import test.org.springdoc.api.v30.app223.apiobjects.Response; + +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class ARestController { + @PostMapping("/parent") + public Response parentEndpoint(@RequestBody AbstractParent parent) { + return null; + } + + @PostMapping("/child") + public Response childEndpoint(@RequestBody AbstractChild child) { + return null; + } +} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v30/app223/SpringDocApp223Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v30/app223/SpringDocApp223Test.java new file mode 100644 index 000000000..ce55a35c6 --- /dev/null +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v30/app223/SpringDocApp223Test.java @@ -0,0 +1,35 @@ +/* + * + * * + * * * + * * * * + * * * * * Copyright 2019-2022 the original author or authors. + * * * * * + * * * * * Licensed under the Apache License, Version 2.0 (the "License"); + * * * * * you may not use this file except in compliance with the License. + * * * * * You may obtain a copy of the License at + * * * * * + * * * * * https://www.apache.org/licenses/LICENSE-2.0 + * * * * * + * * * * * Unless required by applicable law or agreed to in writing, software + * * * * * distributed under the License is distributed on an "AS IS" BASIS, + * * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * * * * * See the License for the specific language governing permissions and + * * * * * limitations under the License. + * * * * + * * * + * * + * + */ + +package test.org.springdoc.api.v30.app223; + +import test.org.springdoc.api.v30.AbstractSpringDocV30Test; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp223Test extends AbstractSpringDocV30Test { + + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v30/app223/apiobjects/AbstractChild.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v30/app223/apiobjects/AbstractChild.java new file mode 100644 index 000000000..de53786c3 --- /dev/null +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v30/app223/apiobjects/AbstractChild.java @@ -0,0 +1,61 @@ +package test.org.springdoc.api.v30.app223.apiobjects; + +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonSubTypes.Type; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeInfo.Id; + +@JsonTypeInfo(use = Id.NAME, property = "type") +@JsonSubTypes({ + @Type(ChildType1.class), + @Type(ChildType2.class) +}) +public abstract class AbstractChild { + private int id; + + public AbstractChild(int id) { + this.id = id; + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } +} + + class ChildType1 extends AbstractChild { + private String childType1Param; + + public ChildType1(int id, String childType1Param) { + super(id); + this.childType1Param = childType1Param; + } + + public String getChildType1Param() { + return childType1Param; + } + + public void setChildType1Param(String childType1Param) { + this.childType1Param = childType1Param; + } +} + +class ChildType2 extends AbstractChild { + private String childType2Param; + + public ChildType2(int id, String childType2Param) { + super(id); + this.childType2Param = childType2Param; + } + + public String getChildType2Param() { + return childType2Param; + } + + public void setChildType2Param(String childType2Param) { + this.childType2Param = childType2Param; + } +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v30/app223/apiobjects/AbstractParent.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v30/app223/apiobjects/AbstractParent.java new file mode 100644 index 000000000..73795f768 --- /dev/null +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v30/app223/apiobjects/AbstractParent.java @@ -0,0 +1,72 @@ +package test.org.springdoc.api.v30.app223.apiobjects; + +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonSubTypes.Type; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeInfo.Id; + + +@JsonTypeInfo(use = Id.NAME, property = "type") +@JsonSubTypes({ + @Type(ParentType1.class), + @Type(ParentType2.class) +}) +public abstract class AbstractParent { + private int id; + + public AbstractParent(int id) { + this.id = id; + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } +} + +class ParentType1 extends AbstractParent { + private String parentType1Param; + private AbstractChild abstractChild; + + public ParentType1(int id, String parentType1Param, AbstractChild abstractChild) { + super(id); + this.parentType1Param = parentType1Param; + this.abstractChild = abstractChild; + } + + public String getParentType1Param() { + return parentType1Param; + } + + public void setParentType1Param(String parentType1Param) { + this.parentType1Param = parentType1Param; + } + + public AbstractChild getAbstractChild() { + return abstractChild; + } + + public void setAbstractChild(AbstractChild abstractChild) { + this.abstractChild = abstractChild; + } +} + +class ParentType2 extends AbstractParent { + private String parentType2Param; + + public ParentType2(int id, String parentType2Param) { + super(id); + this.parentType2Param = parentType2Param; + } + + public String getParentType2Param() { + return parentType2Param; + } + + public void setParentType2Param(String parentType2Param) { + this.parentType2Param = parentType2Param; + } +} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v30/app223/apiobjects/Response.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v30/app223/apiobjects/Response.java new file mode 100644 index 000000000..71dfdf576 --- /dev/null +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v30/app223/apiobjects/Response.java @@ -0,0 +1,4 @@ +package test.org.springdoc.api.v30.app223.apiobjects; + +public record Response(AbstractParent abstractParent, AbstractChild abstractChild) { +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.0.1/app223.json b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.0.1/app223.json new file mode 100644 index 000000000..31ab9d5f6 --- /dev/null +++ b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.0.1/app223.json @@ -0,0 +1,228 @@ +{ + "openapi": "3.0.1", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/parent": { + "post": { + "tags": [ + "a-rest-controller" + ], + "operationId": "parentEndpoint", + "requestBody": { + "content": { + "application/json": { + "schema": { + "oneOf": [ + { + "$ref": "#/components/schemas/ParentType1" + }, + { + "$ref": "#/components/schemas/ParentType2" + } + ] + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/Response" + } + } + } + } + } + } + }, + "/child": { + "post": { + "tags": [ + "a-rest-controller" + ], + "operationId": "childEndpoint", + "requestBody": { + "content": { + "application/json": { + "schema": { + "oneOf": [ + { + "$ref": "#/components/schemas/ChildType1" + }, + { + "$ref": "#/components/schemas/ChildType2" + } + ] + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/Response" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "AbstractChild": { + "required": [ + "type" + ], + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int32" + }, + "type": { + "type": "string" + } + }, + "discriminator": { + "propertyName": "type" + } + }, + "AbstractParent": { + "required": [ + "type" + ], + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int32" + }, + "type": { + "type": "string" + } + }, + "discriminator": { + "propertyName": "type" + } + }, + "ChildType1": { + "type": "object", + "allOf": [ + { + "$ref": "#/components/schemas/AbstractChild" + }, + { + "type": "object", + "properties": { + "childType1Param": { + "type": "string" + } + } + } + ] + }, + "ChildType2": { + "type": "object", + "allOf": [ + { + "$ref": "#/components/schemas/AbstractChild" + }, + { + "type": "object", + "properties": { + "childType2Param": { + "type": "string" + } + } + } + ] + }, + "ParentType1": { + "type": "object", + "allOf": [ + { + "$ref": "#/components/schemas/AbstractParent" + }, + { + "type": "object", + "properties": { + "parentType1Param": { + "type": "string" + }, + "abstractChild": { + "oneOf": [ + { + "$ref": "#/components/schemas/ChildType1" + }, + { + "$ref": "#/components/schemas/ChildType2" + } + ] + } + } + } + ] + }, + "ParentType2": { + "type": "object", + "allOf": [ + { + "$ref": "#/components/schemas/AbstractParent" + }, + { + "type": "object", + "properties": { + "parentType2Param": { + "type": "string" + } + } + } + ] + }, + "Response": { + "type": "object", + "properties": { + "abstractParent": { + "oneOf": [ + { + "$ref": "#/components/schemas/ParentType1" + }, + { + "$ref": "#/components/schemas/ParentType2" + } + ] + }, + "abstractChild": { + "oneOf": [ + { + "$ref": "#/components/schemas/ChildType1" + }, + { + "$ref": "#/components/schemas/ChildType2" + } + ] + } + } + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app105-3.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app105-3.json index bccc4af1b..ff9c8392e 100644 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app105-3.json +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app105-3.json @@ -34,12 +34,12 @@ "requestBody": { "description": "Pet object that needs to be added to the store", "content": { - "application/json": { + "application/xml": { "schema": { "$ref": "#/components/schemas/Pet" } }, - "application/xml": { + "application/json": { "schema": { "$ref": "#/components/schemas/Pet" } @@ -87,12 +87,12 @@ "requestBody": { "description": "Pet object that needs to be added to the store", "content": { - "application/json": { + "application/xml": { "schema": { "$ref": "#/components/schemas/Pet" } }, - "application/xml": { + "application/json": { "schema": { "$ref": "#/components/schemas/Pet" } @@ -128,142 +128,6 @@ ] } }, - "/pet/findByStatus": { - "get": { - "tags": [ - "pet" - ], - "summary": "Finds Pets by status", - "description": "Multiple status values can be provided with comma separated strings", - "operationId": "findPetsByStatus", - "parameters": [ - { - "name": "status", - "in": "query", - "description": "Status values that need to be considered for filter", - "required": true, - "schema": { - "type": "array", - "items": { - "type": "string" - } - } - } - ], - "responses": { - "200": { - "description": "successful operation", - "content": { - "application/json": { - "schema": { - "type": "array", - "items": { - "$ref": "#/components/schemas/Pet" - } - } - }, - "application/xml": { - "schema": { - "type": "array", - "items": { - "$ref": "#/components/schemas/Pet" - } - } - } - } - }, - "400": { - "description": "Invalid status value", - "content": { - "*/*": { - "schema": { - "type": "object", - "additionalProperties": { - "type": "object" - } - } - } - } - } - }, - "security": [ - { - "petstore_auth": [ - "write:pets", - "read:pets" - ] - } - ] - } - }, - "/pet/findByTags": { - "get": { - "tags": [ - "pet" - ], - "summary": "Finds Pets by tags", - "description": "Muliple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.", - "operationId": "findPetsByTags", - "parameters": [ - { - "name": "tags", - "in": "query", - "description": "Tags to filter by", - "required": true, - "schema": { - "type": "array", - "items": { - "type": "string" - } - } - } - ], - "responses": { - "200": { - "description": "successful operation", - "content": { - "application/json": { - "schema": { - "type": "array", - "items": { - "$ref": "#/components/schemas/Pet" - } - } - }, - "application/xml": { - "schema": { - "type": "array", - "items": { - "$ref": "#/components/schemas/Pet" - } - } - } - } - }, - "400": { - "description": "Invalid tag value", - "content": { - "*/*": { - "schema": { - "type": "object", - "additionalProperties": { - "type": "object" - } - } - } - } - } - }, - "security": [ - { - "petstore_auth": [ - "write:pets", - "read:pets" - ] - } - ] - } - }, "/pet/{petId}": { "get": { "tags": [ @@ -285,21 +149,6 @@ } ], "responses": { - "200": { - "description": "successful operation", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/Pet" - } - }, - "application/xml": { - "schema": { - "$ref": "#/components/schemas/Pet" - } - } - } - }, "400": { "description": "Invalid ID supplied", "content": { @@ -316,15 +165,30 @@ "404": { "description": "Pet not found", "content": { - "application/json": { + "application/xml": { "schema": { "$ref": "#/components/schemas/Pet" } }, + "application/json": { + "schema": { + "$ref": "#/components/schemas/Pet" + } + } + } + }, + "200": { + "description": "successful operation", + "content": { "application/xml": { "schema": { "$ref": "#/components/schemas/Pet" } + }, + "application/json": { + "schema": { + "$ref": "#/components/schemas/Pet" + } } } } @@ -504,6 +368,19 @@ } }, "responses": { + "400": { + "description": "the map", + "content": { + "*/*": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object" + } + } + } + } + }, "200": { "description": "successful operation", "content": { @@ -513,9 +390,111 @@ } } } + } + }, + "security": [ + { + "petstore_auth": [ + "write:pets", + "read:pets" + ] + } + ] + } + }, + "/pet/findByTags": { + "get": { + "tags": [ + "pet" + ], + "summary": "Finds Pets by tags", + "description": "Muliple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.", + "operationId": "findPetsByTags", + "parameters": [ + { + "name": "tags", + "in": "query", + "description": "Tags to filter by", + "required": true, + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + } + ], + "responses": { + "400": { + "description": "Invalid tag value", + "content": { + "*/*": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object" + } + } + } + } }, + "200": { + "description": "successful operation", + "content": { + "application/xml": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Pet" + } + } + }, + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Pet" + } + } + } + } + } + }, + "security": [ + { + "petstore_auth": [ + "write:pets", + "read:pets" + ] + } + ] + } + }, + "/pet/findByStatus": { + "get": { + "tags": [ + "pet" + ], + "summary": "Finds Pets by status", + "description": "Multiple status values can be provided with comma separated strings", + "operationId": "findPetsByStatus", + "parameters": [ + { + "name": "status", + "in": "query", + "description": "Status values that need to be considered for filter", + "required": true, + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + } + ], + "responses": { "400": { - "description": "the map", + "description": "Invalid status value", "content": { "*/*": { "schema": { @@ -526,6 +505,27 @@ } } } + }, + "200": { + "description": "successful operation", + "content": { + "application/xml": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Pet" + } + } + }, + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Pet" + } + } + } + } } }, "security": [ @@ -553,26 +553,8 @@ "type": "string", "description": "The Name." } - } - }, - "ModelApiResponse": { - "type": "object", - "properties": { - "code": { - "type": "integer", - "description": "The Code.", - "format": "int32" - }, - "message": { - "type": "string", - "description": "The Message." - }, - "type": { - "type": "string", - "description": "The Type." - } }, - "description": "The type Model api response." + "description": "The type Category." }, "Pet": { "required": [ @@ -581,14 +563,14 @@ ], "type": "object", "properties": { - "category": { - "$ref": "#/components/schemas/Category" - }, "id": { "type": "integer", "description": "The Id.", "format": "int64" }, + "category": { + "$ref": "#/components/schemas/Category" + }, "name": { "type": "string", "description": "The Name.", @@ -601,6 +583,13 @@ "type": "string" } }, + "tags": { + "type": "array", + "description": "The Tags.", + "items": { + "$ref": "#/components/schemas/Tag" + } + }, "status": { "type": "string", "description": "pet status in the store", @@ -609,13 +598,6 @@ "pending", "sold" ] - }, - "tags": { - "type": "array", - "description": "The Tags.", - "items": { - "$ref": "#/components/schemas/Tag" - } } }, "description": "The type Pet." @@ -632,7 +614,27 @@ "type": "string", "description": "The Name." } - } + }, + "description": "The type Tag." + }, + "ModelApiResponse": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "description": "The Code.", + "format": "int32" + }, + "type": { + "type": "string", + "description": "The Type." + }, + "message": { + "type": "string", + "description": "The Message." + } + }, + "description": "The type Model api response." } }, "securitySchemes": { @@ -646,8 +648,8 @@ "implicit": { "authorizationUrl": "http://petstore.swagger.io/oauth/dialog", "scopes": { - "read:pets": "read your pets", - "write:pets": "modify pets in your account" + "write:pets": "modify pets in your account", + "read:pets": "read your pets" } } } diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app2.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app2.json index a0c5620f9..3a0de8a56 100644 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app2.json +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app2.json @@ -193,12 +193,12 @@ "requestBody": { "description": "Pet object that needs to be added to the store", "content": { - "application/json": { + "application/xml": { "schema": { "$ref": "#/components/schemas/Pet" } }, - "application/xml": { + "application/json": { "schema": { "$ref": "#/components/schemas/Pet" } @@ -246,12 +246,12 @@ "requestBody": { "description": "Pet object that needs to be added to the store", "content": { - "application/json": { + "application/xml": { "schema": { "$ref": "#/components/schemas/Pet" } }, - "application/xml": { + "application/json": { "schema": { "$ref": "#/components/schemas/Pet" } @@ -1163,7 +1163,8 @@ "type": "string", "description": "The Name." } - } + }, + "description": "The type Category." }, "Pet": { "required": [ @@ -1223,7 +1224,8 @@ "type": "string", "description": "The Name." } - } + }, + "description": "The type Tag." }, "Order": { "type": "object",