@Test public void shouldCreatePropertyParametersFromPetstoreSwagger() throws IOException { final String specification = resource("/openapi/v3/petstore.json"); final Oas30Document openApiDoc = (Oas30Document) Library.readDocumentFromJSONString(specification); final Oas30Parameter petIdPathParameter = (Oas30Parameter) openApiDoc.paths.getPathItem("/pet/{petId}").get.getParameters().get(0); final Oas30Schema petIdSchema = Oas30ModelHelper.getSchema(petIdPathParameter).orElseThrow(IllegalStateException::new); final ConfigurationProperty configurationProperty = Oas30ParameterGenerator.createPropertyFromParameter(petIdPathParameter, petIdSchema.type, Oas30ParameterGenerator.javaTypeFor(petIdSchema), petIdSchema.default_, petIdSchema.enum_); final ConfigurationProperty expected = new ConfigurationProperty.Builder() .componentProperty(false) .deprecated(false) .description("ID of pet to return") .displayName("petId") .group("producer") .javaType(Long.class.getName()) .kind("property") .required(true) .secret(false) .type("integer") .build(); assertThat(configurationProperty).isEqualTo(expected); }
static String javaTypeFor(final Oas30Schema schema) { if (OasModelHelper.isArrayType(schema)) { final Oas30Schema items = (Oas30Schema) schema.items; final String elementType = items.type; final String elementFormat = items.format; return JsonSchemaHelper.javaTypeFor(elementType, elementFormat) + "[]"; } final String format = schema.format; return JsonSchemaHelper.javaTypeFor(schema.type, format); }
Oas30ParameterGenerator extends OpenApiParameterGenerator<Oas30Document> { static String javaTypeFor(final Oas30Schema schema) { if (OasModelHelper.isArrayType(schema)) { final Oas30Schema items = (Oas30Schema) schema.items; final String elementType = items.type; final String elementFormat = items.format; return JsonSchemaHelper.javaTypeFor(elementType, elementFormat) + "[]"; } final String format = schema.format; return JsonSchemaHelper.javaTypeFor(schema.type, format); } }
Oas30ParameterGenerator extends OpenApiParameterGenerator<Oas30Document> { static String javaTypeFor(final Oas30Schema schema) { if (OasModelHelper.isArrayType(schema)) { final Oas30Schema items = (Oas30Schema) schema.items; final String elementType = items.type; final String elementFormat = items.format; return JsonSchemaHelper.javaTypeFor(elementType, elementFormat) + "[]"; } final String format = schema.format; return JsonSchemaHelper.javaTypeFor(schema.type, format); }  }
Oas30ParameterGenerator extends OpenApiParameterGenerator<Oas30Document> { static String javaTypeFor(final Oas30Schema schema) { if (OasModelHelper.isArrayType(schema)) { final Oas30Schema items = (Oas30Schema) schema.items; final String elementType = items.type; final String elementFormat = items.format; return JsonSchemaHelper.javaTypeFor(elementType, elementFormat) + "[]"; } final String format = schema.format; return JsonSchemaHelper.javaTypeFor(schema.type, format); }   }
Oas30ParameterGenerator extends OpenApiParameterGenerator<Oas30Document> { static String javaTypeFor(final Oas30Schema schema) { if (OasModelHelper.isArrayType(schema)) { final Oas30Schema items = (Oas30Schema) schema.items; final String elementType = items.type; final String elementFormat = items.format; return JsonSchemaHelper.javaTypeFor(elementType, elementFormat) + "[]"; } final String format = schema.format; return JsonSchemaHelper.javaTypeFor(schema.type, format); }    }