} else if (property instanceof StringProperty) { StringProperty stringProperty = (StringProperty) property; List<String> enums = stringProperty.getEnum(); if (CollectionUtils.isNotEmpty(enums)) { type = new EnumType(stringProperty.getTitle(), enums); } else if (isNotBlank(stringProperty.getFormat())) { type = new BasicType(stringProperty.getType(), stringProperty.getTitle(), stringProperty.getFormat()); } else { type = new BasicType(stringProperty.getType(), stringProperty.getTitle()); type = new ObjectType(property.getTitle(), ((ObjectProperty) property).getProperties()); } else if (property instanceof IntegerProperty) { IntegerProperty integerProperty = (IntegerProperty) property; List<Integer> enums = integerProperty.getEnum(); if (CollectionUtils.isNotEmpty(enums)) { type = new EnumType(integerProperty.getTitle(), enumValuesAsString); } else if (isNotBlank(integerProperty.getFormat())) { type = new BasicType(integerProperty.getType(), integerProperty.getTitle(), integerProperty.getFormat()); } else { type = new BasicType(property.getType(), property.getTitle());
/** * Retrieves the pattern of a property * * @return the pattern of the property */ public Optional<String> getPattern() { if (property instanceof StringProperty) { StringProperty stringProperty = (StringProperty) property; return Optional.ofNullable(stringProperty.getPattern()); } else if (property instanceof UUIDProperty) { UUIDProperty uuidProperty = (UUIDProperty) property; return Optional.ofNullable(uuidProperty.getPattern()); } return Optional.empty(); }
/** * Retrieves the maxLength of a property * * @return the maxLength of the property */ public Optional<Integer> getMaxlength() { if (property instanceof StringProperty) { StringProperty stringProperty = (StringProperty) property; return Optional.ofNullable(stringProperty.getMaxLength()); } else if (property instanceof UUIDProperty) { UUIDProperty uuidProperty = (UUIDProperty) property; return Optional.ofNullable(uuidProperty.getMaxLength()); } return Optional.empty(); }
@Override public JavaType doConvert(SwaggerToClassGenerator swaggerToClassGenerator, Object property) { StringProperty stringProperty = (StringProperty) property; List<String> enums = stringProperty.getEnum(); return findJavaType(swaggerToClassGenerator, stringProperty.getType(), stringProperty.getFormat(), enums); } }
property = new StringProperty(); break; case "boolean": property = new BooleanProperty(); break; case "array": property = new ArrayProperty(); break; case "number": case "integer": property = new IntegerProperty(); break; default:
@Override public Model getCREATEModel(Representation rep) { return new ModelImpl() .property("name", new StringProperty()) .property("locale", new StringProperty().example("en")) .property("localePreferred", new BooleanProperty()._default(false)) .property("conceptNameType", new EnumProperty(ConceptNameType.class)) .required("name").required("locale"); }
ArraySchema arraySchema = Json.mapper().convertValue(schema, ArraySchema.class); Property items = ((ArrayProperty) schema).getItems(); Schema itemsSchema = convert(items); arraySchema.setItems(itemsSchema); if (((ArrayProperty) schema).getMaxItems() != null) { arraySchema.setMaxItems(((ArrayProperty) schema).getMaxItems()); if (((ArrayProperty) schema).getMinItems() != null) { result.setExample(schema.getExample()); if ("object".equals(schema.getType()) && (result.getProperties() != null) && (result.getProperties().size() > 0)) { Map<String, Schema> properties = new HashMap<>(); StringProperty sp = (StringProperty) schema; result.setMinLength(sp.getMinLength()); result.setMaxLength(sp.getMaxLength()); result.setPattern(sp.getPattern()); if (schema.getVendorExtensions() != null) { Object nullableExtension = schema.getVendorExtensions().get("x-nullable"); if (nullableExtension != null) {
return new StringProperty() .required(annotation.required()) .example(annotation.example().isEmpty() ? null : annotation.example()) .description(annotation.value().isEmpty() ? null : annotation.value()); ArrayProperty property = new ArrayProperty(); property.setRequired(annotation.required()); return property .example(annotation.example()) DoubleProperty property = new DoubleProperty(); property.setRequired(annotation.required()); return property .example(annotation.example()) .description(annotation.value()); IntegerProperty property = new IntegerProperty(); property.setRequired(annotation.required()); property.setExample(annotation.example()); LongProperty property = new LongProperty(); property.setRequired(annotation.required()); property.setExample(annotation.example()); BooleanProperty property = new BooleanProperty(); property.setRequired(annotation.required()); property.setExample(annotation.example());
private static Map<String, Property> initProperties() { Map<String, Property> properties = new LinkedHashMap<>(); properties.put(PROPERTY_ONE_NAME, new StringProperty() .example(PROPERTY_ONE_EXAMPLE) .required(true) .description(PROPERTY_ONE_DESCRIPTION)); properties.put(PROPERTY_TWO_NAME, new StringProperty() .example(PROPERTY_TWO_EXAMPLE) .required(true) .description(PROPERTY_TWO_DESCRIPTION)); IntegerProperty integerProp = new IntegerProperty(); LongProperty longProp = new LongProperty(); BooleanProperty booleanProp = new BooleanProperty(); integerProp.setExample(""); longProp.setExample(""); booleanProp.setExample(""); properties.put(ARRAY_PROP_NAME, new ArrayProperty().example("").description("")); properties.put(DOUBLE_PROP_NAME, new DoubleProperty().example("").description("")); properties.put(FLOAT_PROP_NAME, new FloatProperty().example("").description("")); properties.put(INTEGER_PROP_NAME, integerProp.description("")); properties.put(LONG_PROP_NAME, longProp.description("")); properties.put(BOOLEAN_PROP_NAME, booleanProp.description("")); properties.put(OBJECT_PROP_NAME, new ObjectProperty().example("").description("")); return properties; } }
public Model propertyToModel(Property property){ String description = property.getDescription(); String type = property.getType(); String format = property.getFormat(); String example = null; ArrayProperty arrayProperty = (ArrayProperty) property; ArrayModel arrayModel = new ArrayModel(); arrayModel.setItems(arrayProperty.getItems()); arrayModel.setDescription(description); arrayModel.setExample(example); arrayModel.setUniqueItems(arrayProperty.getUniqueItems()); model.setPattern(stringProperty.getPattern()); model.setMinLength(stringProperty.getMinLength()); model.setMaxLength(stringProperty.getMaxLength()); model.setEnum(stringProperty.getEnum());
if (byte.class == objectClass || Byte.class == objectClass) { swaggerProperty = new StringProperty("byte"); } else if (char.class == objectClass || Character.class == objectClass) { StringProperty property = new StringProperty(); property.setMaxLength(1); swaggerProperty = property; } else if (short.class == objectClass || Short.class == objectClass) { } else if (long.class == objectClass || Long.class == objectClass) { swaggerProperty = new StringProperty(); } else if (Date.class == objectClass || Timestamp.class == objectClass) { StringProperty property = new StringProperty(); property.setPattern("HH:mm:ss"); swaggerProperty = property; } else if (UUID.class == objectClass) { StringProperty property = new StringProperty(); List<String> enumValues = new ArrayList<>(); for (Object enumValue : objectClass.getEnumConstants()) { enumValues.add(((Enum) enumValue).name()); property.setEnum(enumValues); swaggerProperty = property; } else if (FileItem.class == objectClass) {
Property p = null; if (param.getAllowMultiple() != null && param.getAllowMultiple() == true) { ArrayProperty arrayProperty = new ArrayProperty(); Property innerType = PropertyBuilder.build(type, format, null); arrayProperty.setItems(innerType); p = arrayProperty; } else { "WARNING! No property detected for parameter '%s' (%s)! Falling back to string!", param.getName(), param.getParamType())); p = new StringProperty(); sp.setType("array"); sp.setCollectionFormat("csv"); sp.setItems(ap.getItems()); } else { sp.setType(p.getType()); sp.setFormat(p.getFormat());
@Override public Model getCREATEModel(Representation rep) { return new ModelImpl() .property("allergen", new ObjectProperty()) //FIXME type .property("severity", new ObjectProperty() .property("uuid", new StringProperty())) .property("comment", new StringProperty()) .property("reactions", new ArrayProperty(new ObjectProperty() .property("allergy", new ObjectProperty().property("uuid", new StringProperty())) .property("reaction", new ObjectProperty().property("uuid", new StringProperty())))) .required("allergen"); }
Boolean wrapped = false; Object example = property.getExample(); if (property instanceof RefProperty) { RefProperty ref = (RefProperty) property; output = new StringExample(example.toString()); } else { String defaultValue = ((StringProperty)property).getDefault(); List<String> enums = ((StringProperty) property).getEnum(); if( enums != null && !enums.isEmpty()) { defaultValue = enums.get(0); Integer defaultValue = ((IntegerProperty) property).getDefault(); List<Integer> enums = ((IntegerProperty) property).getEnum(); if( enums != null && !enums.isEmpty()) { defaultValue = enums.get(0); Long defaultValue = ((LongProperty) property).getDefault(); Float defaultValue = ((FloatProperty) property).getDefault(); Double defaultValue = ((DoubleProperty) property).getDefault(); Boolean defaultValue = ((BooleanProperty)property).getDefault(); output = new BooleanExample( defaultValue == null ? SAMPLE_BOOLEAN_PROPERTY_VALUE : defaultValue.booleanValue());
if (String.class.isAssignableFrom(fieldType)) property = new StringProperty(); property = new IntegerProperty(); property = new LongProperty(); property = new BooleanProperty(); property = new ArrayProperty(new StringProperty()); property = new StringProperty()._enum(enums); property = new StringProperty(); log.debug("Field type \"" + fieldType.getName() + "\" is a property type \"" + property.getType() + "\"."); return property;
return fillProperty(new ArrayProperty(iProperty), mapping); bProperty.setRequired(false); return bProperty; return fillProperty(new BooleanProperty(), mapping); return fillProperty(new IntegerProperty(), mapping); return fillProperty(new LongProperty(), mapping); return fillProperty(new FloatProperty(), mapping); return fillProperty(new DoubleProperty(), mapping); return fillProperty(new StringProperty(), mapping);
@Override public Model getCREATEModel(Representation rep) { return new ModelImpl().property("person", new StringProperty().example("uuid")) .property("obsDatetime", new DateTimeProperty()).property("concept", new StringProperty().example("uuid")) .property("location", new StringProperty()).property("order", new StringProperty()) .property("encounter", new StringProperty()).property("accessionNumber", new StringProperty()) .property("groupMembers", new ArrayProperty(new StringProperty())) .property("valueCodedName", new StringProperty()).property("comment", new StringProperty()) .property("voided", new BooleanProperty()).property("value", new StringProperty()) .property("valueModifier", new StringProperty()) .required("person").required("obsDatetime").required("concept"); }
defProperty = new BooleanProperty(); } else if (BluePrintConstants.DATA_TYPE_INTEGER.equals(propertyDefinition.getType())) { StringProperty stringProperty = new StringProperty(); stringProperty.setType("integer"); defProperty = stringProperty; } else if (BluePrintConstants.DATA_TYPE_FLOAT.equals(propertyDefinition.getType())) { StringProperty stringProperty = new StringProperty(); stringProperty.setFormat("float"); defProperty = stringProperty; } else if (BluePrintConstants.DATA_TYPE_TIMESTAMP.equals(propertyDefinition.getType())) { defProperty = dateTimeProperty; } else { defProperty = new StringProperty(); ArrayProperty arrayProperty = new ArrayProperty(); if (propertyDefinition.getEntrySchema() != null) { String entrySchema = propertyDefinition.getEntrySchema().getType(); if (!BluePrintTypes.validPrimitiveTypes().contains(entrySchema)) { Property innerType = new RefProperty("#/definitions/" + entrySchema); arrayProperty.setItems(innerType); } else { Property innerType = new StringProperty(); arrayProperty.setItems(innerType); defProperty = new RefProperty("#/definitions/" + propertyDefinition.getType());
@Override public Model getGETModel(Representation rep) { ModelImpl modelImpl = ((ModelImpl) super.getGETModel(rep)) .property("uuid", new StringProperty()) .property("display", new StringProperty()); if (rep instanceof DefaultRepresentation || rep instanceof FullRepresentation) { modelImpl .property("value", new StringProperty()) .property("locale", new StringProperty().example("en")); //FIXME type } return modelImpl; }
public Model getGETModel(Representation rep) { ModelImpl model = ((ModelImpl) super.getGETModel(rep)); if (rep instanceof DefaultRepresentation || rep instanceof FullRepresentation) { model .property("uuid", new StringProperty()) .property("display", new StringProperty()) .property("name", new StringProperty()) .property("description", new StringProperty()) .property("voided", new StringProperty()) .property("memberIds", new ArrayProperty(new IntegerProperty())); //FIXME } return model; }