Search in sources :

Example 1 with ModelResolver

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

the class EnumPropertyTest method setup.

@BeforeMethod
public void setup() {
    ModelResolver.enumsAsRef = false;
    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 2 with ModelResolver

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

the class InheritedBeanTest method setup.

@BeforeMethod
public void setup() {
    ModelResolver.composedModelPropertiesAsSibling = false;
    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 3 with ModelResolver

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

the class Ticket2189Test 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 4 with ModelResolver

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

the class Ticket2915Test method testPropertyName.

@Test
public void testPropertyName() throws Exception {
    final ModelResolver modelResolver = new ModelResolver(mapper());
    final ModelConverterContextImpl context = new ModelConverterContextImpl(modelResolver);
    final Schema model = context.resolve(new AnnotatedType(TestObject2915.class));
    SerializationMatchers.assertEqualsToYaml(context.getDefinedModels(), "QuantitativeValue:\n" + "  required:\n" + "  - value\n" + "  type: object\n" + "  properties:\n" + "    value:\n" + "      type: number\n" + "      format: double\n" + "    unitText:\n" + "      type: string\n" + "    unitCode:\n" + "      type: string\n" + "  description: A combination of a value and associated unit\n" + "TestObject2616:\n" + "  type: object\n" + "  properties:\n" + "    name:\n" + "      type: string\n" + "    perServing:\n" + "      $ref: '#/components/schemas/QuantitativeValue'\n" + "    per100Gram:\n" + "      $ref: '#/components/schemas/QuantitativeValue'\n" + "  description: Nutritional value specification");
}
Also used : AnnotatedType(io.swagger.v3.core.converter.AnnotatedType) TestObject2915(io.swagger.v3.core.resolving.resources.TestObject2915) 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 5 with ModelResolver

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

the class Ticket2740CyclicTest method testCyclicBean.

@Test
public void testCyclicBean() throws Exception {
    final ModelResolver modelResolver = new ModelResolver(mapper());
    final ModelConverterContextImpl context = new ModelConverterContextImpl(modelResolver);
    final Schema model = context.resolve(new AnnotatedType(MyThing.class));
    SerializationMatchers.assertEqualsToYaml(model, "type: object\n" + "properties:\n" + "  otherThings:\n" + "    uniqueItems: true\n" + "    type: array\n" + "    description: Other related things\n" + "    items:\n" + "      $ref: '#/components/schemas/MyThing'\n" + "description: Thing");
}
Also used : AnnotatedType(io.swagger.v3.core.converter.AnnotatedType) Schema(io.swagger.v3.oas.models.media.Schema) MyThing(io.swagger.v3.core.resolving.resources.MyThing) 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)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