SwaggerFieldConverter { public static Property fieldToProperty(Field field) { final String typeClass = field.getType().getTypeClassName(); Property property = toNumberProperty(typeClass); if (property != null) { return property; } property = toDateProperty(typeClass); if (property != null) { return property; } property = toComboboxProperty(field); if (property != null) { return property; } return toMiscProperty(typeClass); } private  SwaggerFieldConverter(); static Property fieldToProperty(Field field); static Parameter lookupParameter(String lookupFieldName, Field field, LookupFieldType lookupFieldType, String paramDescription);  }
@Test public void shouldConvertFieldsToProperties() { Property property = SwaggerFieldConverter.fieldToProperty(field(DateTime.class)); verifySimpleProperty(property, "string", "date-time"); property = SwaggerFieldConverter.fieldToProperty(field(Date.class)); verifySimpleProperty(property, "string", "date-time"); property = SwaggerFieldConverter.fieldToProperty(field(LocalDate.class)); verifySimpleProperty(property, "string", "date"); property = SwaggerFieldConverter.fieldToProperty(field(String.class)); verifySimpleProperty(property, "string", null); property = SwaggerFieldConverter.fieldToProperty(field(Locale.class)); verifySimpleProperty(property, "string", null); property = SwaggerFieldConverter.fieldToProperty(field(Integer.class)); verifySimpleProperty(property, "integer", "int32"); property = SwaggerFieldConverter.fieldToProperty(field(Long.class)); verifySimpleProperty(property, "integer", "int64"); property = SwaggerFieldConverter.fieldToProperty(field(Double.class)); verifySimpleProperty(property, "number", "double"); property = SwaggerFieldConverter.fieldToProperty(field(Boolean.class)); verifySimpleProperty(property, "boolean", null); }
@Test public void shouldConvertComboboxes() { Property property = SwaggerFieldConverter.fieldToProperty(field(List.class)); verifySimpleProperty(property, "string", null); Entity entity = new Entity("org.example.Something"); Field field = FieldTestHelper.fieldWithComboboxSettings(entity, "name", "disp name", List.class, true, false, asList("a", "b", "c")); property = SwaggerFieldConverter.fieldToProperty(field); verifyComboboxProperty(property, true); FieldTestHelper.setAllowUserSupplied(field, true); property = SwaggerFieldConverter.fieldToProperty(field); verifyComboboxProperty(property, false); }