Java Code Examples for springfox.documentation.spi.service.contexts.OperationContext#getParameters()
The following examples show how to use
springfox.documentation.spi.service.contexts.OperationContext#getParameters() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PageableParameterBuilderPlugin.java From jhipster with Apache License 2.0 | 6 votes |
/** {@inheritDoc} */ @Override public void apply(OperationContext context) { List<Parameter> parameters = newArrayList(); for (ResolvedMethodParameter methodParameter : context.getParameters()) { ResolvedType resolvedType = methodParameter.getParameterType(); if (pageableType.equals(resolvedType)) { ParameterContext parameterContext = new ParameterContext(methodParameter, new ParameterBuilder(), context.getDocumentationContext(), context.getGenericsNamingStrategy(), context); parameters.add(createPageParameter(parameterContext)); parameters.add(createSizeParameter(parameterContext)); parameters.add(createSortParameter(parameterContext)); context.operationBuilder().parameters(parameters); } } }
Example 2
Source File: RequestToPoOperationBuilder.java From jframework with Apache License 2.0 | 5 votes |
private List<Parameter> readParameters(final OperationContext context) { List<ResolvedMethodParameter> methodParameters = context.getParameters(); final List<Parameter> parameterList = new ArrayList<>(); for (ResolvedMethodParameter methodParameter : methodParameters) { ResolvedType alternate = context.alternateFor(methodParameter.getParameterType()); if (!shouldIgnore(methodParameter, alternate, context.getIgnorableParameterTypes()) && isRequestFormToPojo(methodParameter)) { readRequestFormToPojo(context, methodParameter); } } return parameterList.stream().filter(((Predicate<Parameter>) Parameter::isHidden).negate()).collect(Collectors.toList()); }
Example 3
Source File: PageableParameterBuilderPlugin.java From albedo with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void apply(OperationContext context) { for (ResolvedMethodParameter methodParameter : context.getParameters()) { ResolvedType resolvedType = methodParameter.getParameterType(); if (pageableType.equals(resolvedType)) { ParameterContext parameterContext = new ParameterContext(methodParameter, new ParameterBuilder(), context.getDocumentationContext(), context.getGenericsNamingStrategy(), context); ModelReference intModel = createModelRefFactory(parameterContext).apply(resolver.resolve(Integer.TYPE)); ModelReference stringModel = createModelRefFactory(parameterContext).apply(resolver.resolve(List.class, String.class)); List<Parameter> parameters = Lists.newArrayList( new ParameterBuilder() .parameterType("query").name("current").modelRef(intModel) .description("Page number of the requested page") .build(), new ParameterBuilder() .parameterType("query").name("size").modelRef(intModel) .description("Size of a page") .build(), new ParameterBuilder() .parameterType("query").name("descs").modelRef(stringModel).allowMultiple(true) .description("Sorting criteria in the format: property(,asc|desc). Default sort order is ascending. Multiple sort criteria are supported.") .build(), new ParameterBuilder() .parameterType("query").name("ascs").modelRef(stringModel).allowMultiple(true) .description("Sorting criteria in the format: property(,asc|desc). Default sort order is ascending. Multiple sort criteria are supported.") .build(), new ParameterBuilder() .parameterType("query").name("queryConditionJson").modelRef(stringModel).allowMultiple(true) .description("search json [{\"fieldName\":\"name\",\"attrType\":\"String\",\"fieldNode\":\"\",\"operate\":\"like\",\"weight\":0,\"value\":\"g\"},{\"fieldName\":\"status\",\"attrType\":\"Integer\",\"fieldNode\":\"\",\"operate\":\"in\",\"weight\":0,\"value\":\"-1\"}]}") .build()); context.operationBuilder().parameters(parameters); } } }
Example 4
Source File: PageableParameterBuilderPlugin.java From spring-cloud-gray with Apache License 2.0 | 4 votes |
@Override public void apply(OperationContext context) { List<ResolvedMethodParameter> methodParameters = context.getParameters(); List<Parameter> parameters = newArrayList(); for (ResolvedMethodParameter methodParameter : methodParameters) { ResolvedType resolvedType = methodParameter.getParameterType(); if (pageableType.equals(resolvedType)) { ParameterContext parameterContext = new ParameterContext(methodParameter, new ParameterBuilder(), context.getDocumentationContext(), context.getGenericsNamingStrategy(), context); Function<ResolvedType, ? extends ModelReference> factory = createModelRefFactory(parameterContext); ModelReference intModel = factory.apply(resolver.resolve(Integer.TYPE)); ModelReference stringModel = factory.apply(resolver.resolve(List.class, String.class)); parameters.add(new ParameterBuilder() .parameterType("queryRecords") .name("page") .modelRef(intModel) .description("Results page you want to retrieve (0..N)").build()); parameters.add(new ParameterBuilder() .parameterType("queryRecords") .name("size") .modelRef(intModel) .description("Number of records per page").build()); parameters.add(new ParameterBuilder() .parameterType("queryRecords") .name("sort") .modelRef(stringModel) .allowMultiple(true) .description("Sorting criteria in the format: property(,asc|desc). " + "Default sort order is ascending. " + "Multiple sort criteria are supported.") .build()); context.operationBuilder().parameters(parameters); } } }
Example 5
Source File: ParametersReader.java From Resource with GNU General Public License v3.0 | 4 votes |
private List<Parameter> readParameters(OperationContext context) { List<Parameter> parameters = Lists.newArrayList(); List<ResolvedMethodParameter> methodParameters = context.getParameters(); Map<String, ApiSingleParam> paramMap = new HashMap<>(); Field[] fields = ModelCache.getInstance().getParamClass().getDeclaredFields(); String type = new String(); for (Field field : fields) { if (field.isAnnotationPresent(ApiSingleParam.class)) { ApiSingleParam param = field.getAnnotation(ApiSingleParam.class); try { String name = (String)field.get(type); paramMap.put(name, param); } catch (Exception e) { } } } for (ResolvedMethodParameter methodParameter : methodParameters) { ParameterContext parameterContext = new ParameterContext(methodParameter, new ParameterBuilder(), context.getDocumentationContext(), context.getGenericsNamingStrategy(), context); Function<ResolvedType, ? extends ModelReference> factory = createModelRefFactory(parameterContext); Optional<ApiJsonObject> annotation = context.findAnnotation(ApiJsonObject.class); if (annotation.isPresent()) { ModelCache.getInstance().setFactory(factory) .setParamMap(paramMap) .addModel(annotation.get()); } } return parameters; }