Search in sources :

Example 6 with ModelConverterContextImpl

use of io.swagger.v3.core.converter.ModelConverterContextImpl 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 ModelConverterContextImpl

use of io.swagger.v3.core.converter.ModelConverterContextImpl 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 ModelConverterContextImpl

use of io.swagger.v3.core.converter.ModelConverterContextImpl 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 ModelConverterContextImpl

use of io.swagger.v3.core.converter.ModelConverterContextImpl 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 ModelConverterContextImpl

use of io.swagger.v3.core.converter.ModelConverterContextImpl 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)29 Schema (io.swagger.v3.oas.models.media.Schema)27 AnnotatedType (io.swagger.v3.core.converter.AnnotatedType)26 Test (org.testng.annotations.Test)24 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)11 ArraySchema (io.swagger.v3.oas.models.media.ArraySchema)8 ModelConverter (io.swagger.v3.core.converter.ModelConverter)6 XML (io.swagger.v3.oas.models.media.XML)4 BeforeMethod (org.testng.annotations.BeforeMethod)4 StringSchema (io.swagger.v3.oas.models.media.StringSchema)3 Map (java.util.Map)3 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 BeforeTest (org.testng.annotations.BeforeTest)2 JsonIdentityInfo (com.fasterxml.jackson.annotation.JsonIdentityInfo)1 JsonIdentityReference (com.fasterxml.jackson.annotation.JsonIdentityReference)1 JsonIgnore (com.fasterxml.jackson.annotation.JsonIgnore)1 JsonIgnoreProperties (com.fasterxml.jackson.annotation.JsonIgnoreProperties)1 JsonProperty (com.fasterxml.jackson.annotation.JsonProperty)1