Search in sources :

Example 26 with ModelConverterContextImpl

use of io.swagger.v3.core.converter.ModelConverterContextImpl in project swagger-core by swagger-api.

the class Ticket2992Test method testLocalTime.

@Test
public void testLocalTime() throws Exception {
    final ModelResolver modelResolver = new ModelResolver(mapper());
    ModelConverterContextImpl context = new ModelConverterContextImpl(modelResolver);
    Schema model = context.resolve(new AnnotatedType(TestObject2992.class));
    SerializationMatchers.assertEqualsToYaml(context.getDefinedModels(), "LocalTime:\n" + "  type: object\n" + "  properties:\n" + "    hour:\n" + "      type: integer\n" + "      format: int32\n" + "    minute:\n" + "      type: integer\n" + "      format: int32\n" + "    second:\n" + "      type: integer\n" + "      format: int32\n" + "    nano:\n" + "      type: integer\n" + "      format: int32\n" + "TestObject2992:\n" + "  type: object\n" + "  properties:\n" + "    name:\n" + "      type: string\n" + "    a:\n" + "      $ref: '#/components/schemas/LocalTime'\n" + "    b:\n" + "      $ref: '#/components/schemas/LocalTime'\n" + "    c:\n" + "      $ref: '#/components/schemas/LocalTime'\n" + "    d:\n" + "      type: string\n" + "      format: date-time\n" + "    e:\n" + "      type: string\n" + "      format: date-time\n" + "    f:\n" + "      type: string\n" + "      format: date-time");
    PrimitiveType.enablePartialTime();
    context = new ModelConverterContextImpl(modelResolver);
    context.resolve(new AnnotatedType(TestObject2992.class));
    SerializationMatchers.assertEqualsToYaml(context.getDefinedModels(), "TestObject2992:\n" + "  type: object\n" + "  properties:\n" + "    name:\n" + "      type: string\n" + "    a:\n" + "      type: string\n" + "      format: partial-time\n" + "    b:\n" + "      type: string\n" + "      format: partial-time\n" + "    c:\n" + "      type: string\n" + "      format: partial-time\n" + "    d:\n" + "      type: string\n" + "      format: date-time\n" + "    e:\n" + "      type: string\n" + "      format: date-time\n" + "    f:\n" + "      type: string\n" + "      format: date-time");
}
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) TestObject2992(io.swagger.v3.core.resolving.resources.TestObject2992) Test(org.testng.annotations.Test)

Example 27 with ModelConverterContextImpl

use of io.swagger.v3.core.converter.ModelConverterContextImpl in project swagger-core by swagger-api.

the class Ticket3063Test 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)

Example 28 with ModelConverterContextImpl

use of io.swagger.v3.core.converter.ModelConverterContextImpl in project swagger-core by swagger-api.

the class Ticket2972Test method testLocalTime.

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

Example 29 with ModelConverterContextImpl

use of io.swagger.v3.core.converter.ModelConverterContextImpl in project swagger-core by swagger-api.

the class Ticket3365Test 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 30 with ModelConverterContextImpl

use of io.swagger.v3.core.converter.ModelConverterContextImpl in project swagger-core by swagger-api.

the class ContainerTest method testArray.

@Test
public void testArray() throws Exception {
    final ModelResolver modelResolver = new ModelResolver(mapper());
    final ModelConverterContextImpl context = new ModelConverterContextImpl(modelResolver);
    final Schema model = context.resolve(new AnnotatedType(ArrayBean.class));
    final Map<String, Schema> props = model.getProperties();
    assertEquals(1, props.size());
    final Schema prop = props.get("a");
    assertNotNull(prop);
    assertEquals(prop.getType(), "array");
    final Schema items = ((ArraySchema) prop).getItems();
    assertNotNull(items);
    assertEquals(items.getType(), "integer");
}
Also used : AnnotatedType(io.swagger.v3.core.converter.AnnotatedType) ArraySchema(io.swagger.v3.oas.models.media.ArraySchema) Schema(io.swagger.v3.oas.models.media.Schema) ArraySchema(io.swagger.v3.oas.models.media.ArraySchema) ModelConverterContextImpl(io.swagger.v3.core.converter.ModelConverterContextImpl) ModelResolver(io.swagger.v3.core.jackson.ModelResolver) Test(org.testng.annotations.Test)

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