Search in sources :

Example 1 with StringPropertyConverter

use of io.servicecomb.swagger.converter.property.StringPropertyConverter in project java-chassis by ServiceComb.

the class ConverterMgr method initConverters.

private static void initConverters() {
    // inner converters
    for (Class<? extends Property> propertyCls : PROPERTY_MAP.keySet()) {
        addInnerConverter(propertyCls);
    }
    converterMap.put(RefProperty.class, new RefPropertyConverter());
    converterMap.put(ArrayProperty.class, new ArrayPropertyConverter());
    converterMap.put(MapProperty.class, new MapPropertyConverter());
    converterMap.put(StringProperty.class, new StringPropertyConverter());
    converterMap.put(ModelImpl.class, new ModelImplConverter());
    converterMap.put(RefModel.class, new RefModelConverter());
    converterMap.put(BodyParameter.class, new BodyParameterConverter());
    converterMap.put(PendingBodyParameter.class, new PendingBodyParameterConverter());
    AbstractSerializableParameterConverter converter = new AbstractSerializableParameterConverter();
    converterMap.put(QueryParameter.class, converter);
    converterMap.put(PathParameter.class, converter);
    converterMap.put(HeaderParameter.class, converter);
    converterMap.put(FormParameter.class, converter);
    converterMap.put(CookieParameter.class, converter);
}
Also used : RefModelConverter(io.servicecomb.swagger.converter.model.RefModelConverter) AbstractSerializableParameterConverter(io.servicecomb.swagger.converter.parameter.AbstractSerializableParameterConverter) PendingBodyParameterConverter(io.servicecomb.swagger.converter.parameter.PendingBodyParameterConverter) BodyParameterConverter(io.servicecomb.swagger.converter.parameter.BodyParameterConverter) PendingBodyParameterConverter(io.servicecomb.swagger.converter.parameter.PendingBodyParameterConverter) RefPropertyConverter(io.servicecomb.swagger.converter.property.RefPropertyConverter) ArrayPropertyConverter(io.servicecomb.swagger.converter.property.ArrayPropertyConverter) MapPropertyConverter(io.servicecomb.swagger.converter.property.MapPropertyConverter) StringPropertyConverter(io.servicecomb.swagger.converter.property.StringPropertyConverter) ModelImplConverter(io.servicecomb.swagger.converter.model.ModelImplConverter)

Example 2 with StringPropertyConverter

use of io.servicecomb.swagger.converter.property.StringPropertyConverter in project java-chassis by ServiceComb.

the class TestProperty method testStringProperty.

@Test
public void testStringProperty() {
    SwaggerGenerator generator = new SwaggerGeneratorForTest(context, null);
    List<String> enums = Arrays.asList("testStringProperty_a", "testStringProperty_b");
    StringProperty sp = new StringProperty();
    sp._enum(enums);
    StringPropertyConverter spc = new StringPropertyConverter();
    JavaType jt = spc.convert(generator.getClassLoader(), generator.ensureGetPackageName(), generator.getSwagger(), sp);
    StringProperty spNew = (StringProperty) ModelConverters.getInstance().readAsProperty(jt);
    Assert.assertEquals(enums, spNew.getEnum());
}
Also used : JavaType(com.fasterxml.jackson.databind.JavaType) StringProperty(io.swagger.models.properties.StringProperty) StringPropertyConverter(io.servicecomb.swagger.converter.property.StringPropertyConverter) SwaggerGeneratorForTest(io.servicecomb.swagger.generator.core.unittest.SwaggerGeneratorForTest) SwaggerGeneratorForTest(io.servicecomb.swagger.generator.core.unittest.SwaggerGeneratorForTest) Test(org.junit.Test)

Aggregations

StringPropertyConverter (io.servicecomb.swagger.converter.property.StringPropertyConverter)2 JavaType (com.fasterxml.jackson.databind.JavaType)1 ModelImplConverter (io.servicecomb.swagger.converter.model.ModelImplConverter)1 RefModelConverter (io.servicecomb.swagger.converter.model.RefModelConverter)1 AbstractSerializableParameterConverter (io.servicecomb.swagger.converter.parameter.AbstractSerializableParameterConverter)1 BodyParameterConverter (io.servicecomb.swagger.converter.parameter.BodyParameterConverter)1 PendingBodyParameterConverter (io.servicecomb.swagger.converter.parameter.PendingBodyParameterConverter)1 ArrayPropertyConverter (io.servicecomb.swagger.converter.property.ArrayPropertyConverter)1 MapPropertyConverter (io.servicecomb.swagger.converter.property.MapPropertyConverter)1 RefPropertyConverter (io.servicecomb.swagger.converter.property.RefPropertyConverter)1 SwaggerGeneratorForTest (io.servicecomb.swagger.generator.core.unittest.SwaggerGeneratorForTest)1 StringProperty (io.swagger.models.properties.StringProperty)1 Test (org.junit.Test)1