private static Collection<QueryParameter> transformMappings(final Iterable<SearchMapping> searchMappings) { // NOSONAR return StreamSupport.stream(searchMappings.spliterator(), false) .map(m -> new QueryParameter().name(m.getAlias()).type("string").description(m.getDescription())) .collect(toList()); } }
private List<Parameter> buildPagingParameters() { List<Parameter> params = new ArrayList<Parameter>(); Parameter limit = new QueryParameter().name("limit") .description("The number of results to return").type("integer"); Parameter startIndex = new QueryParameter().name("startIndex") .description("The offset at which to start").type("integer"); params.add(limit); params.add(startIndex); return params; }
/** * @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"); }
.name("page[number]") .description("Number of pages to return. Can be used with page[size]") .type("integer") ); .name("page[size]") .description("Number of elements per page. Can be used with page[number]") .type("integer") ); .name("page[offset]") .description("Offset from 0 to start paginating. Can be used with page[limit]") .type("integer") ); .name("page[limit]") .description("Maximum number of items to return. Can be used with page[offset]") .type("integer") ); .type("string") );
.type("string") .name("filter[" + typeName + "]") .description("Filters the collection of " + typeName + " using a 'disjoint' RSQL expression")); .type("string") .name("filter") .description("Filters the collection of " + typeName + " using a 'joined' RSQL expression")); .type("string") .name("filter[" + typeName + "." + name + "][" + op.getNotation() + "]") .description("Filters the collection of " + typeName + " by the attribute "
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"); }
/** * Build a {@link QueryParameter} Swagger object defined by {@link ApiImplicitParam} * to use for documentation. * * @param apiParam The annotation which documents the parameter. * @return The {@link QueryParameter} object to be used in {@link Swagger} */ public static QueryParameter queryParameter(ApiImplicitParam apiParam) { return new QueryParameter() .name(apiParam.name()) .description(apiParam.value()) .required(apiParam.required()) .type(apiParam.dataType()); }
/** * @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"); }
operation.addParameter(pathParameter); } else if (paramType.equals("query")) { QueryParameter pathParameter = new QueryParameter().name(paramName).type(dataType); pathParameter.setRequired(param.required()); operation.addParameter(pathParameter); final String type = getSwaggerDataType(parameterType); final String paramName = (annotation != null) ? annotation.name() : endpointParamNames[i]; final QueryParameter param = new QueryParameter().type(type).name(paramName); if (annotation != null) { param.description(annotation.value());
operation.addParameter(pathParameter); } else if (paramType.equals("query")) { QueryParameter pathParameter = new QueryParameter().name(paramName).type(dataType); pathParameter.setRequired(param.required()); operation.addParameter(pathParameter); final String type = getSwaggerDataType(parameterType); final String paramName = (annotation != null) ? annotation.name() : endpointParamNames[i]; final QueryParameter param = new QueryParameter().type(type).name(paramName); if (annotation != null) { param.description(annotation.value());
.type("string"); .type("string") ._enum(Arrays.asList("ref", "default", "full", "custom")); Parameter p = new QueryParameter().type("string"); p.setName(requiredParameter.getName()); parameterMap.put(requiredParameter.getName(), p); Parameter p = new QueryParameter().type("string"); p.setName(optionalParameter.getName()); p.setDescription(buildSearchParameterDependencyString(searchQuery.getRequiredParameters()));
deleteOperation.setDescription("The resource will be voided/retired unless purge = 'true'"); QueryParameter purgeParam = new QueryParameter().name("purge").type("boolean"); deleteOperation.parameter(purgeParam); } else {
pm = new QueryParameter().type(param.getType()); break;
.description(QUERY_PARAM_VALUE) .required(true) .type(SwaggerDocumentation.DataTypes.DATA_TYPE_STRING);
.type("string") ._enum(Arrays.asList("ref", "default", "full", "custom"));