private Property readAsPropertyIfPrimitive(Type type) { if (com.github.kongchen.swagger.docgen.util.TypeUtils.isPrimitive(type)) { return ModelConverters.getInstance().readAsProperty(type); } else { String msg = String.format("Can't use non-primitive type: %s as request parameter", type); log.error(msg); // fallback to string if type is simple wrapper for String to support legacy code JavaType ct = constructType(type); if (isSimpleWrapperForString(ct.getRawClass())) { log.warn(String.format("Non-primitive type: %s used as string for request parameter", type)); return new StringProperty(); } } return null; }
/** * Constructs a singular resource identifier * @param relationshipType the type of resource */ public Relationship(String relationshipType) { super(); property("type", new StringProperty()._enum(relationshipType)); property("id", new StringProperty()); } }
@Override public Model getUPDATEModel(Representation representation) { return new ModelImpl() .property("name", new StringProperty()); //FIXME missing props }
@Override public Model getCREATEModel(Representation rep) { return ((ModelImpl) super.getCREATEModel(rep)) .property("code", new StringProperty()) .property("conceptSource", new StringProperty()) .property("version", new StringProperty()) .required("code").required("conceptSource"); }
protected Property getNamePatternProperty(MetaClass entityClass) { Property namePatternProperty = new StringProperty(); Class<?> javaClass = entityClass.getJavaClass(); NamePattern namePatternAnnotation = javaClass.getAnnotation(NamePattern.class); if (namePatternAnnotation != null) { namePatternProperty.setDefault(namePatternAnnotation.value()); } return namePatternProperty; }
protected Property getErrorSchema() { return new ObjectProperty() .property("error", new StringProperty().description("Error message")) .property("details", new StringProperty().description("Detailed error description")); } }
@Override public Model getCREATEModel(Representation rep) { return ((ModelImpl) super.getCREATEModel(rep)) .property("datatypeClassname", new StringProperty()) .property("minOccurs", new IntegerProperty()) .property("maxOccurs", new IntegerProperty()) .property("datatypeConfig", new StringProperty()) .property("preferredHandlerClassname", new StringProperty()) .property("handlerConfig", new StringProperty()) .required("datatypeClassname"); }
public IncludedResource() { super(); /* These will always be empty. */ ObjectProperty attributes = new ObjectProperty(); ObjectProperty relationships = new ObjectProperty(); property("type", new StringProperty()); property("id", new StringProperty()); property("attributes", attributes); property("relationships", relationships); } }
public Resource() { super(); attributes = new ObjectProperty(); relationships = new ObjectProperty(); idProperty = new StringProperty(); typeProperty = new StringProperty(); property("type", typeProperty); property("id", idProperty); property("attributes", attributes); property("relationships", relationships); }
@Override public void objectModel(ModelImpl objectModel) { // can't use fillMap for this because of bogus set method implemetnation in // ModelImpl if (objectModel.getProperties() == null) { objectModel.addProperty("x", new StringProperty()); // faults in an empty map first objectModel.getProperties().clear(); } objectModel.setRequired(fillList(objectModel.getRequired())); }
@Override public Model getCREATEModel(Representation rep) { return ((ModelImpl) super.getCREATEModel(rep)) .property("retired", new BooleanProperty()) .property("retiredReason", new StringProperty()); }
@Override public Model getCREATEModel(Representation rep) { return new ModelImpl() .property("ingredient", new StringProperty().example("uuid")) .property("strength", new DoubleProperty()) .property("units", new StringProperty().example("uuid")) .required("ingredient"); }
/** * @return the swagger PathParameter for this particular path segment. */ private Parameter getPathParameter() { String typeName = dictionary.getJsonAliasFor(type); Parameter param = new PathParameter() .name(typeName + "Id") .description(typeName + " Identifier") .property(new StringProperty()); return param; }
@Override public Model getCREATEModel(Representation rep) { return new ModelImpl() .property("name", new StringProperty()) .property("description", new StringProperty()) .property("memberIds", new ArrayProperty(new IntegerProperty())) //FIXME .required("name").required("description").required("memberIds"); }
protected Parameter generateGetOperationParam(Pair<String, String> param) { boolean paramIsArray = param.getSecond() != null && param.getSecond().contains(ARRAY_SIGNATURE); return new QueryParameter() .name(param.getFirst()) .required(true) .type(paramIsArray ? "array" : "string") .items(paramIsArray ? new StringProperty() : null); }
/** * @return the JSON-API 'include' query parameter for some GET operations. */ private Parameter getIncludeParameter() { List<String> relationshipNames = dictionary.getRelationships(type); return new QueryParameter() .type("array") .name("include") .description("Selects the set of relationships that should be expanded as a compound document in " + "the result.") .items(new StringProperty()._enum(relationshipNames)) .collectionFormat("csv"); }
/** * @return the JSON-API 'field' query parameter for some GET operations. */ private Parameter getSparseFieldsParameter() { String typeName = dictionary.getJsonAliasFor(type); List<String> fieldNames = dictionary.getAllFields(type); return new QueryParameter() .type("array") .name("fields[" + typeName + "]") .description("Selects the set of " + typeName + " fields that should be returned in the result.") .items(new StringProperty()._enum(fieldNames)) .collectionFormat("csv"); }
@Override public Model getCREATEModel(Representation rep) { ModelImpl model = ((ModelImpl) super.getCREATEModel(rep)) .property("concept", new StringProperty().example("uuid")) .property("retired", new BooleanProperty()) .required("concept").required("description"); if (rep instanceof FullRepresentation) { model .property("concept", new RefProperty("#/definitions/ConceptCreate")); } return model; }
@Override public Model getUPDATEModel(Representation rep) { return new ModelImpl() .property("description", new StringProperty()) .property("privileges", new ArrayProperty(new RefProperty("#/definitions/PrivilegeCreate"))) .property("inheritedRoles", new ArrayProperty(new RefProperty("#/definitions/RoleCreate"))); }
@Override public Model getCREATEModel(Representation rep) { ModelImpl model = new ModelImpl() .property("person", new StringProperty().example("uuid")) .property("identifiers", new ArrayProperty(new RefProperty("#/definitions/PatientIdentifierCreate"))) .required("person").required("identifiers"); if (rep instanceof FullRepresentation) { model .property("person", new RefProperty("#/definitions/PersonCreate")); } return model; }