Search in sources :

Example 6 with ModelResolver

use of io.swagger.v3.core.jackson.ModelResolver in project swagger-core by swagger-api.

the class Ticket2884Test method test2884.

@Test
public void test2884() throws Exception {
    final ModelResolver modelResolver = new ModelResolver(mapper());
    ModelConverterContextImpl context = new ModelConverterContextImpl(modelResolver);
    Ticket2884ModelClass a = new Ticket2884ModelClass();
    Schema model = context.resolve(new AnnotatedType(Ticket2884Model.class));
    SerializationMatchers.assertEqualsToYaml(context.getDefinedModels(), "Ticket2884Model:\n" + "  type: object\n" + "  properties:\n" + "    Ticket2884Model:\n" + "      type: object");
    context = new ModelConverterContextImpl(modelResolver);
    model = context.resolve(new AnnotatedType(Ticket2884ModelClass.class));
    SerializationMatchers.assertEqualsToYaml(context.getDefinedModels(), "Ticket2884ModelClass:\n" + "  type: object\n" + "  properties:\n" + "    Ticket2884ModelClass:\n" + "      type: object\n" + "      properties:\n" + "        bar:\n" + "          type: string\n" + "        foo:\n" + "          type: array\n" + "          items:\n" + "            type: string\n");
}
Also used : AnnotatedType(io.swagger.v3.core.converter.AnnotatedType) Ticket2884Model(io.swagger.v3.core.resolving.resources.Ticket2884Model) Schema(io.swagger.v3.oas.models.media.Schema) Ticket2884ModelClass(io.swagger.v3.core.resolving.resources.Ticket2884ModelClass) ModelConverterContextImpl(io.swagger.v3.core.converter.ModelConverterContextImpl) ModelResolver(io.swagger.v3.core.jackson.ModelResolver) Test(org.testng.annotations.Test)

Example 7 with ModelResolver

use of io.swagger.v3.core.jackson.ModelResolver in project swagger-core by swagger-api.

the class Ticket3348Test method beforeMethod.

@BeforeMethod
public void beforeMethod() {
    modelResolver = new ModelResolver(new ObjectMapper());
    context = new ModelConverterContextImpl(modelResolver);
}
Also used : ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) ModelConverterContextImpl(io.swagger.v3.core.converter.ModelConverterContextImpl) ModelResolver(io.swagger.v3.core.jackson.ModelResolver) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 8 with ModelResolver

use of io.swagger.v3.core.jackson.ModelResolver in project swagger-core by swagger-api.

the class Ticket3624Test method testSelfReferencingOptional.

@Test
public void testSelfReferencingOptional() throws Exception {
    final ModelResolver modelResolver = new ModelResolver(mapper());
    ModelConverterContextImpl context = new ModelConverterContextImpl(modelResolver);
    Schema model = context.resolve(new AnnotatedType(ModelContainer.class));
    Yaml.prettyPrint(context.getDefinedModels());
    SerializationMatchers.assertEqualsToYaml(context.getDefinedModels(), "Model:\n" + "  type: object\n" + "  properties:\n" + "    model:\n" + "      $ref: '#/components/schemas/Model'\n" + "ModelContainer:\n" + "  type: object\n" + "  properties:\n" + "    model:\n" + "      $ref: '#/components/schemas/Model'\n");
}
Also used : AnnotatedType(io.swagger.v3.core.converter.AnnotatedType) Schema(io.swagger.v3.oas.models.media.Schema) ModelConverterContextImpl(io.swagger.v3.core.converter.ModelConverterContextImpl) ModelResolver(io.swagger.v3.core.jackson.ModelResolver) Test(org.testng.annotations.Test)

Example 9 with ModelResolver

use of io.swagger.v3.core.jackson.ModelResolver in project swagger-core by swagger-api.

the class Ticket3703Test method testSelfReferencingOptional.

@Test
public void testSelfReferencingOptional() throws Exception {
    final ModelResolver modelResolver = new ModelResolver(mapper());
    ModelConverterContextImpl context = new ModelConverterContextImpl(modelResolver);
    Schema model = context.resolve(new AnnotatedType(ModelContainer.class));
    SerializationMatchers.assertEqualsToYaml(context.getDefinedModels(), "Model:\n" + "  type: object\n" + "  properties:\n" + "    model:\n" + "      $ref: '#/components/schemas/Model'\n" + "ModelContainer:\n" + "  type: object\n" + "  properties:\n" + "    model:\n" + "      $ref: '#/components/schemas/Model'\n" + "    bytes:\n" + "      type: string\n" + "      format: byte");
}
Also used : AnnotatedType(io.swagger.v3.core.converter.AnnotatedType) Schema(io.swagger.v3.oas.models.media.Schema) ModelConverterContextImpl(io.swagger.v3.core.converter.ModelConverterContextImpl) ModelResolver(io.swagger.v3.core.jackson.ModelResolver) Test(org.testng.annotations.Test)

Example 10 with ModelResolver

use of io.swagger.v3.core.jackson.ModelResolver in project swagger-core by swagger-api.

the class Ticket3030Test method setup.

@BeforeTest
public void setup() {
    modelResolver = new ModelResolver(new ObjectMapper());
    context = new ModelConverterContextImpl(modelResolver);
}
Also used : ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) ModelConverterContextImpl(io.swagger.v3.core.converter.ModelConverterContextImpl) ModelResolver(io.swagger.v3.core.jackson.ModelResolver) BeforeTest(org.testng.annotations.BeforeTest)

Aggregations

ModelConverterContextImpl (io.swagger.v3.core.converter.ModelConverterContextImpl)33 ModelResolver (io.swagger.v3.core.jackson.ModelResolver)30 AnnotatedType (io.swagger.v3.core.converter.AnnotatedType)25 Schema (io.swagger.v3.oas.models.media.Schema)25 Test (org.testng.annotations.Test)24 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)11 ArraySchema (io.swagger.v3.oas.models.media.ArraySchema)7 ModelConverter (io.swagger.v3.core.converter.ModelConverter)6 BeforeMethod (org.testng.annotations.BeforeMethod)5 XML (io.swagger.v3.oas.models.media.XML)3 BeforeTest (org.testng.annotations.BeforeTest)3 OpenAPISchema2JsonSchema (io.swagger.v3.core.util.OpenAPISchema2JsonSchema)2 StringSchema (io.swagger.v3.oas.models.media.StringSchema)2 Map (java.util.Map)2 MyThing (io.swagger.v3.core.resolving.resources.MyThing)1 TestObject2915 (io.swagger.v3.core.resolving.resources.TestObject2915)1 TestObject2972 (io.swagger.v3.core.resolving.resources.TestObject2972)1 TestObject2992 (io.swagger.v3.core.resolving.resources.TestObject2992)1 TestObject3697 (io.swagger.v3.core.resolving.resources.TestObject3697)1 Ticket2862Model (io.swagger.v3.core.resolving.resources.Ticket2862Model)1