-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
schema resolution options - Phase 3: global all-of-ref
- Loading branch information
Showing
6 changed files
with
141 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
112 changes: 112 additions & 0 deletions
112
modules/swagger-jaxrs2/src/test/java/io/swagger/v3/jaxrs2/SchemaResolutionAllOfRefTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
package io.swagger.v3.jaxrs2; | ||
|
||
import io.swagger.v3.core.converter.ModelConverters; | ||
import io.swagger.v3.jaxrs2.matchers.SerializationMatchers; | ||
import io.swagger.v3.jaxrs2.schemaResolution.SchemaResolutionResource; | ||
import io.swagger.v3.oas.integration.SwaggerConfiguration; | ||
import io.swagger.v3.oas.models.OpenAPI; | ||
import io.swagger.v3.oas.models.media.Schema; | ||
import org.testng.annotations.Test; | ||
|
||
public class SchemaResolutionAllOfRefTest { | ||
|
||
@Test | ||
public void testSchemaResolutionAllOfRef() { | ||
ModelConverters.reset(); | ||
Reader reader = new Reader(new SwaggerConfiguration().openAPI(new OpenAPI()).schemaResolution(Schema.SchemaResolution.ALL_OF_REF)); | ||
OpenAPI openAPI = reader.read(SchemaResolutionResource.class); | ||
String yaml = "openapi: 3.0.1\n" + | ||
"paths:\n" + | ||
" /test/inlineSchemaFirst:\n" + | ||
" get:\n" + | ||
" operationId: inlineSchemaFirst\n" + | ||
" responses:\n" + | ||
" default:\n" + | ||
" description: default response\n" + | ||
" content:\n" + | ||
" '*/*':\n" + | ||
" schema:\n" + | ||
" $ref: \"#/components/schemas/InlineSchemaFirst\"\n" + | ||
" /test/inlineSchemaSecond:\n" + | ||
" get:\n" + | ||
" operationId: inlineSchemaSecond\n" + | ||
" requestBody:\n" + | ||
" content:\n" + | ||
" '*/*':\n" + | ||
" schema:\n" + | ||
" description: InlineSchemaSecond API\n" + | ||
" allOf:\n" + | ||
" - $ref: \"#/components/schemas/InlineSchemaSecond\"\n" + | ||
" responses:\n" + | ||
" default:\n" + | ||
" description: default response\n" + | ||
" content:\n" + | ||
" '*/*':\n" + | ||
" schema:\n" + | ||
" $ref: \"#/components/schemas/InlineSchemaSecond\"\n" + | ||
"components:\n" + | ||
" schemas:\n" + | ||
" InlineSchemaFirst:\n" + | ||
" type: object\n" + | ||
" properties:\n" + | ||
" property1:\n" + | ||
" description: InlineSchemaFirst property 1\n" + | ||
" nullable: true\n" + | ||
" allOf:\n" + | ||
" - $ref: \"#/components/schemas/InlineSchemaPropertyFirst\"\n" + | ||
" property2:\n" + | ||
" description: ' InlineSchemaFirst property 2'\n" + | ||
" example: example 2\n" + | ||
" allOf:\n" + | ||
" - $ref: \"#/components/schemas/InlineSchemaPropertyFirst\"\n" + | ||
" InlineSchemaPropertyFirst:\n" + | ||
" type: object\n" + | ||
" properties:\n" + | ||
" bar:\n" + | ||
" type: string\n" + | ||
" description: property\n" + | ||
" example: example\n" + | ||
" InlineSchemaPropertySecond:\n" + | ||
" type: object\n" + | ||
" properties:\n" + | ||
" bar:\n" + | ||
" $ref: \"#/components/schemas/InlineSchemaSimple\"\n" + | ||
" description: propertysecond\n" + | ||
" example: examplesecond\n" + | ||
" InlineSchemaPropertySimple:\n" + | ||
" type: object\n" + | ||
" properties:\n" + | ||
" bar:\n" + | ||
" type: string\n" + | ||
" description: property\n" + | ||
" InlineSchemaSecond:\n" + | ||
" type: object\n" + | ||
" properties:\n" + | ||
" foo:\n" + | ||
" type: string\n" + | ||
" propertySecond1:\n" + | ||
" description: InlineSchemaSecond property 1\n" + | ||
" nullable: true\n" + | ||
" allOf:\n" + | ||
" - $ref: \"#/components/schemas/InlineSchemaPropertySecond\"\n" + | ||
" property2:\n" + | ||
" description: InlineSchemaSecond property 2\n" + | ||
" example: InlineSchemaSecond example 2\n" + | ||
" allOf:\n" + | ||
" - $ref: \"#/components/schemas/InlineSchemaPropertyFirst\"\n" + | ||
" InlineSchemaSimple:\n" + | ||
" type: object\n" + | ||
" properties:\n" + | ||
" property1:\n" + | ||
" description: property 1\n" + | ||
" allOf:\n" + | ||
" - $ref: \"#/components/schemas/InlineSchemaPropertySimple\"\n" + | ||
" property2:\n" + | ||
" description: property 2\n" + | ||
" example: example\n" + | ||
" allOf:\n" + | ||
" - $ref: \"#/components/schemas/InlineSchemaPropertySimple\"\n"; | ||
SerializationMatchers.assertEqualsToYaml(openAPI, yaml); | ||
ModelConverters.reset(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters