use of io.swagger.v3.oas.models.media.IntegerSchema in project swagger-core by swagger-api.
the class PropertySerializationTest method serializeLongProperty.
@Test(description = "it should serialize a LongProperty")
public void serializeLongProperty() throws IOException {
final IntegerSchema p = new IntegerSchema().format("int64")._default(8675309);
final String json = "{\"type\":\"integer\",\"format\":\"int64\",\"default\":8675309}";
assertEquals(m.writeValueAsString(p), json);
}
use of io.swagger.v3.oas.models.media.IntegerSchema in project swagger-core by swagger-api.
the class HiddenFieldTest method testHiddenField.
@Test(description = "it should ignore a hidden field")
public void testHiddenField() {
final Map<String, Schema> models = ModelConverters.getInstance().read(ModelWithHiddenFields.class);
final Schema model = models.get("ModelWithHiddenFields");
assertNotNull(model);
assertEquals(model.getProperties().size(), 2);
final Schema idValue = (Schema) model.getProperties().get("id");
assertTrue(idValue instanceof IntegerSchema);
assertTrue(model.getRequired().contains("id"));
final Schema nameValue = (Schema) model.getProperties().get("name");
assertTrue(nameValue instanceof StringSchema);
final Schema passwordValue = (Schema) model.getProperties().get("password");
assertNull(passwordValue);
}
use of io.swagger.v3.oas.models.media.IntegerSchema in project swagger-core by swagger-api.
the class ReaderTest method testTicket3029.
@Test(description = "Parameter with ref")
public void testTicket3029() {
Components components = new Components();
components.addParameters("id", new Parameter().description("Id Description").schema(new IntegerSchema()).in(ParameterIn.QUERY.toString()).example(1).required(true));
OpenAPI oas = new OpenAPI().info(new Info().description("info")).components(components);
Reader reader = new Reader(oas);
OpenAPI openAPI = reader.read(RefParameter3029Resource.class);
String yaml = "openapi: 3.0.1\n" + "info:\n" + " description: info\n" + "paths:\n" + " /2:\n" + " get:\n" + " summary: Simple get operation\n" + " operationId: sendPayload2\n" + " parameters:\n" + " - $ref: '#/components/parameters/id'\n" + " responses:\n" + " default:\n" + " description: default response\n" + " content:\n" + " '*/*': {}\n" + " /1:\n" + " get:\n" + " summary: Simple get operation\n" + " operationId: sendPayload1\n" + " parameters:\n" + " - $ref: '#/components/parameters/id'\n" + " responses:\n" + " default:\n" + " description: default response\n" + " content:\n" + " '*/*': {}\n" + "components:\n" + " parameters:\n" + " id:\n" + " in: query\n" + " description: Id Description\n" + " required: true\n" + " schema:\n" + " type: integer\n" + " format: int32\n" + " example: 1\n";
SerializationMatchers.assertEqualsToYaml(openAPI, yaml);
}
use of io.swagger.v3.oas.models.media.IntegerSchema in project swagger-core by swagger-api.
the class SchemaTests method AdditionalPropertiesSchema.
@Test
public void AdditionalPropertiesSchema() {
Map<String, Schema> schemas = new HashMap<>();
schemas.put("IntegerSchema", new IntegerSchema().description("simple integer schema").multipleOf(new BigDecimal(3)).minimum(new BigDecimal(6)).additionalProperties(new StringSchema()));
}
use of io.swagger.v3.oas.models.media.IntegerSchema in project swagger-core by swagger-api.
the class ModelSerializerTest method convertModel.
@Test(description = "it should convert a model")
public void convertModel() throws JsonProcessingException {
final Schema pet = new Schema();
final Map<String, Schema> props = new LinkedHashMap<String, Schema>();
props.put("intValue", new IntegerSchema());
props.put("longValue", new IntegerSchema().format("int64"));
props.put("dateValue", new DateSchema());
props.put("dateTimeValue", new DateTimeSchema());
pet.setProperties(props);
pet.setRequired(Arrays.asList("intValue", "name"));
final String json = "{\n" + " \"required\":[\n" + " \"intValue\"\n" + " ],\n" + " \"properties\":{\n" + " \"intValue\":{\n" + " \"type\":\"integer\",\n" + " \"format\":\"int32\"\n" + " },\n" + " \"longValue\":{\n" + " \"type\":\"integer\",\n" + " \"format\":\"int64\"\n" + " },\n" + " \"dateValue\":{\n" + " \"type\":\"string\",\n" + " \"format\":\"date\"\n" + " },\n" + " \"dateTimeValue\":{\n" + " \"type\":\"string\",\n" + " \"format\":\"date-time\"\n" + " }\n" + " }\n" + "}";
SerializationMatchers.assertEqualsToJson(pet, json);
}
Aggregations