-
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 1: global inline
- Loading branch information
Showing
17 changed files
with
710 additions
and
19 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
172 changes: 172 additions & 0 deletions
172
modules/swagger-core/src/test/java/io/swagger/v3/core/resolving/InlineResolvingTest.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,172 @@ | ||
package io.swagger.v3.core.resolving; | ||
|
||
import io.swagger.v3.core.converter.AnnotatedType; | ||
import io.swagger.v3.core.converter.ModelConverterContextImpl; | ||
import io.swagger.v3.core.jackson.ModelResolver; | ||
import io.swagger.v3.core.matchers.SerializationMatchers; | ||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import org.testng.annotations.Test; | ||
|
||
public class InlineResolvingTest extends SwaggerTestBase{ | ||
|
||
@Test | ||
public void testInlineResolving() { | ||
|
||
final ModelResolver modelResolver = new ModelResolver(mapper()).openapi31(false).schemaResolution(io.swagger.v3.oas.models.media.Schema.SchemaResolution.INLINE); | ||
final ModelConverterContextImpl c = new ModelConverterContextImpl(modelResolver); | ||
// ModelConverters c = ModelConverters.getInstance(false, io.swagger.v3.oas.models.media.Schema.SchemaResolution.INLINE); | ||
c.resolve(new AnnotatedType(InlineSchemaFirst.class)); | ||
|
||
String expectedYaml = "InlineSchemaFirst:\n" + | ||
" type: object\n" + | ||
" properties:\n" + | ||
" property1:\n" + | ||
" type: object\n" + | ||
" description: InlineSchemaFirst property 1\n" + | ||
" nullable: true\n" + | ||
" example: example\n" + | ||
" property2:\n" + | ||
" type: object\n" + | ||
" description: ' InlineSchemaFirst property 2'\n" + | ||
" example: example 2\n" + | ||
"InlineSchemaPropertyFirst:\n" + | ||
" type: object\n" + | ||
" description: property\n" + | ||
" example: example\n"; | ||
|
||
SerializationMatchers.assertEqualsToYaml(c.getDefinedModels(), expectedYaml); | ||
// stringSchemaMap = c.readAll(InlineSchemaSecond.class); | ||
c.resolve(new AnnotatedType(InlineSchemaSecond.class)); | ||
expectedYaml = "InlineSchemaFirst:\n" + | ||
" type: object\n" + | ||
" properties:\n" + | ||
" property1:\n" + | ||
" type: object\n" + | ||
" description: InlineSchemaFirst property 1\n" + | ||
" nullable: true\n" + | ||
" example: example\n" + | ||
" property2:\n" + | ||
" type: object\n" + | ||
" description: ' InlineSchemaFirst property 2'\n" + | ||
" example: example 2\n" + | ||
"InlineSchemaPropertyFirst:\n" + | ||
" type: object\n" + | ||
" description: property\n" + | ||
" example: example\n" + | ||
"InlineSchemaPropertySecond:\n" + | ||
" type: object\n" + | ||
" properties:\n" + | ||
" bar:\n" + | ||
" type: object\n" + | ||
" properties:\n" + | ||
" property1:\n" + | ||
" type: object\n" + | ||
" description: property 1\n" + | ||
" property2:\n" + | ||
" type: object\n" + | ||
" description: property 2\n" + | ||
" example: example\n" + | ||
" description: propertysecond\n" + | ||
" nullable: true\n" + | ||
" example: examplesecond\n" + | ||
"InlineSchemaPropertySimple:\n" + | ||
" type: object\n" + | ||
" description: property\n" + | ||
" example: example\n" + | ||
"InlineSchemaSecond:\n" + | ||
" type: object\n" + | ||
" properties:\n" + | ||
" propertySecond1:\n" + | ||
" type: object\n" + | ||
" properties:\n" + | ||
" bar:\n" + | ||
" type: object\n" + | ||
" properties:\n" + | ||
" property1:\n" + | ||
" type: object\n" + | ||
" description: property 1\n" + | ||
" property2:\n" + | ||
" type: object\n" + | ||
" description: property 2\n" + | ||
" example: example\n" + | ||
" description: InlineSchemaSecond property 1\n" + | ||
" nullable: true\n" + | ||
" example: examplesecond\n" + | ||
" property2:\n" + | ||
" type: object\n" + | ||
" description: InlineSchemaSecond property 2\n" + | ||
" example: InlineSchemaSecond example 2\n" + | ||
"InlineSchemaSimple:\n" + | ||
" type: object\n" + | ||
" properties:\n" + | ||
" property1:\n" + | ||
" type: object\n" + | ||
" description: property 1\n" + | ||
" property2:\n" + | ||
" type: object\n" + | ||
" description: property 2\n" + | ||
" example: example\n"; | ||
SerializationMatchers.assertEqualsToYaml(c.getDefinedModels(), expectedYaml); | ||
} | ||
|
||
static class InlineSchemaFirst { | ||
|
||
// public String foo; | ||
|
||
@Schema(description = "InlineSchemaFirst property 1", nullable = true) | ||
public InlineSchemaPropertyFirst property1; | ||
|
||
|
||
private InlineSchemaPropertyFirst property2; | ||
|
||
@Schema(description = " InlineSchemaFirst property 2", example = "example 2") | ||
public InlineSchemaPropertyFirst getProperty2() { | ||
return null; | ||
} | ||
} | ||
|
||
static class InlineSchemaSecond { | ||
|
||
// public String foo; | ||
|
||
@Schema(description = "InlineSchemaSecond property 1", nullable = true) | ||
public InlineSchemaPropertySecond propertySecond1; | ||
|
||
|
||
private InlineSchemaPropertyFirst property2; | ||
|
||
@Schema(description = "InlineSchemaSecond property 2", example = "InlineSchemaSecond example 2") | ||
public InlineSchemaPropertyFirst getProperty2() { | ||
return null; | ||
} | ||
} | ||
|
||
@Schema(description = "property", example = "example") | ||
static class InlineSchemaPropertyFirst { | ||
// public String bar; | ||
} | ||
|
||
@Schema(description = "propertysecond", example = "examplesecond") | ||
static class InlineSchemaPropertySecond { | ||
public InlineSchemaSimple bar; | ||
} | ||
|
||
static class InlineSchemaSimple { | ||
|
||
@Schema(description = "property 1") | ||
public InlineSchemaPropertySimple property1; | ||
|
||
|
||
private InlineSchemaPropertySimple property2; | ||
|
||
@Schema(description = "property 2", example = "example") | ||
public InlineSchemaPropertySimple getProperty2() { | ||
return null; | ||
} | ||
} | ||
|
||
@Schema(description = "property") | ||
static class InlineSchemaPropertySimple { | ||
// public String bar; | ||
} | ||
} |
Oops, something went wrong.