use of org.testng.annotations.Test in project swagger-core by swagger-api.
the class SnakeCaseConverterTest method testConvert.
@Test(description = "it should change naming style")
public void testConvert() {
// add the custom converter
final SnakeCaseConverter snakeCaseConverter = new SnakeCaseConverter();
final ModelConverters converters = new ModelConverters();
converters.addConverter(snakeCaseConverter);
final Map<String, Model> models = converters.readAll(SnakeCaseModel.class);
final String json = "{" + " \"bar\":{" + " \"type\":\"object\"," + " \"properties\":{" + " \"foo\":{" + " \"type\":\"string\"" + " }" + " }" + " }," + " \"snake_case_model\":{" + " \"type\":\"object\"," + " \"properties\":{" + " \"bar\":{" + " \"$ref\":\"#/definitions/bar\"" + " }," + " \"title\":{" + " \"type\":\"string\"" + " }" + " }," + " \"xml\":{" + " \"name\":\"snakeCaseModel\"" + " }" + " }" + "}";
SerializationMatchers.assertEqualsToJson(models, json);
}
use of org.testng.annotations.Test in project swagger-core by swagger-api.
the class ParameterSerializationTest method serializeQueryParameter.
@Test(description = "it should serialize a QueryParameter")
public void serializeQueryParameter() {
final QueryParameter p = new QueryParameter().property(new StringProperty());
final String json = "{\"in\":\"query\",\"required\":false,\"type\":\"string\"}";
SerializationMatchers.assertEqualsToJson(p, json);
}
use of org.testng.annotations.Test in project swagger-core by swagger-api.
the class ParameterSerializationTest method testIssue1765.
@Test(description = "should serialize correctly typed numeric enums")
public void testIssue1765() throws Exception {
String yaml = "swagger: '2.0'\n" + "paths:\n" + " /test:\n" + " get:\n" + " parameters:\n" + " - name: \"days\"\n" + " in: \"path\"\n" + " required: true\n" + " type: \"integer\"\n" + " format: \"int32\"\n" + " enum:\n" + " - 1\n" + " - 2\n" + " - 3\n" + " - 4\n" + " - 5\n" + " responses:\n" + " default:\n" + " description: great";
Swagger swagger = Yaml.mapper().readValue(yaml, Swagger.class);
SerializationMatchers.assertEqualsToYaml(swagger, yaml);
}
use of org.testng.annotations.Test in project swagger-core by swagger-api.
the class ParameterSerializationTest method deserializePathParameter.
@Test(description = "it should deserialize a PathParameter")
public void deserializePathParameter() throws IOException {
final String json = "{\"in\":\"query\",\"required\":true,\"type\":\"string\"}";
final Parameter p = m.readValue(json, Parameter.class);
SerializationMatchers.assertEqualsToJson(p, json);
assertTrue(p.getRequired());
}
use of org.testng.annotations.Test in project swagger-core by swagger-api.
the class ParameterSerializationTest method testIncorrectLong.
@Test(description = "should serialize incorrect long value as string")
public void testIncorrectLong() {
final QueryParameter param = new QueryParameter();
param.setDefaultValue("test");
param.setType("integer");
param.setFormat("1nt64");
final String json = "{\"in\":\"query\",\"required\":false,\"type\":\"integer\",\"default\":\"test\",\"format\":\"1nt64\"}";
SerializationMatchers.assertEqualsToJson(param, json);
}
Aggregations