/** * @return the JSON-API 'sort' query parameter for some GET operations. */ private Parameter getSortParameter() { List<String> filterAttributes = dictionary.getAttributes(type).stream() .filter((name) -> { Class<?> attributeClass = dictionary.getType(type, name); return (attributeClass.isPrimitive() || String.class.isAssignableFrom(attributeClass)); }) .map((name) -> Arrays.asList(name, "-" + name)) .flatMap(Collection::stream) .collect(Collectors.toList()); return new QueryParameter() .name("sort") .type("array") .description("Sorts the collection on the selected attributes. A prefix of '-' sorts descending") .items(new StringProperty()._enum(filterAttributes)) .collectionFormat("csv"); }
/** * 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()); } }
property = new StringProperty()._enum(enums);
/** * @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 representation) { ModelImpl model = new ModelImpl() .property("names", new ArrayProperty(new RefProperty("#/definitions/PersonNameCreate"))) .property("gender", new StringProperty()._enum("M")._enum("F")) .property("age", new IntegerProperty()) .property("birthdate", new DateProperty()) .property("birthdateEstimated", new BooleanProperty()._default(false)) .property("dead", new BooleanProperty()._default(false)) .property("deathDate", new DateProperty()) .property("causeOfDeath", new StringProperty()) .property("addresses", new ArrayProperty(new RefProperty("#/definitions/PersonAddressCreate"))) .property("attributes", new ArrayProperty(new RefProperty("#/definitions/PersonAttributeCreate"))); model.setRequired(Arrays.asList("names", "gender")); return model; }
StringProperty prop = new StringProperty(); if (pd.enumValues != null) { prop._enum(Arrays.asList(pd.enumValues));
@Override public Model getUPDATEModel(Representation representation) { return new ModelImpl() .property("dead", new BooleanProperty()) .property("causeOfDeath", new StringProperty()) .property("deathDate", new DateProperty()) .property("age", new IntegerProperty()) .property("gender", new StringProperty()._enum("M")._enum("F")) .property("birthdate", new DateProperty()) .property("birthdateEstimated", new BooleanProperty()._default(false)) .property("preferredName", new StringProperty().example("uuid")) .property("preferredAddress", new StringProperty().example("uuid")) .property("attributes", new ArrayProperty(new RefProperty("#/definitions/PersonAttributeCreate"))) .required("dead").required("causeOfDeath"); }