protected void updateOperationParameters(List<Parameter> parentParameters, Map<String, String> regexMap, Operation operation) { if (parentParameters != null) { for (Parameter param : parentParameters) { operation.parameter(param); } } for (Parameter param : operation.getParameters()) { String pattern = regexMap.get(param.getName()); if (pattern != null) { param.setPattern(pattern); } } }
parameter.setName(parameterNames[i]); operation.parameter(parameter);
/** * Add the {@code operation} parameter depending on its type. * * @param operation The operation for which to add a parameter description * @param apiParam The parameter description */ private void setOperationParam(Operation operation, ApiImplicitParam apiParam) { switch (apiParam.paramType()) { case SwaggerDocumentation.ParamTypes.PARAM_TYPE_BODY: operation.parameter(bodyParameter(apiParam)); break; case SwaggerDocumentation.ParamTypes.PARAM_TYPE_FORM: operation.parameter(formParameter(apiParam)); break; case SwaggerDocumentation.ParamTypes.PARAM_TYPE_HEADER: operation.parameter(headerParameter(apiParam)); break; case SwaggerDocumentation.ParamTypes.PARAM_TYPE_PATH: operation.parameter(pathParameter(apiParam)); break; case SwaggerDocumentation.ParamTypes.PARAM_TYPE_QUERY: operation.parameter(queryParameter(apiParam)); break; default: break; } }
public void applyImplicitParameters(Swagger swagger, ReaderContext context, Operation operation, Method method) { final ApiImplicitParams implicitParams = method.getAnnotation(ApiImplicitParams.class); if (implicitParams != null && implicitParams.value().length > 0) { for (ApiImplicitParam param : implicitParams.value()) { final Parameter p = readImplicitParam(swagger, param); if (p != null) { operation.parameter(p); } } } }
@Override public void applyImplicitParameters(ReaderContext context, Operation operation, Method method) { final ApiImplicitParams implicitParams = method.getAnnotation(ApiImplicitParams.class); if (implicitParams != null && implicitParams.value().length > 0) { for (ApiImplicitParam param : implicitParams.value()) { final Parameter p = readImplicitParam(context.getSwagger(), param); if (p != null) { operation.parameter(p); } } } }
private void applyParametersV2(ReaderContext context, Operation operation, String name, Type type,Class<?> cls, Annotation[] annotations, Annotation[] interfaceParamAnnotations) { Annotation apiParam = null; if (annotations != null) { for (Annotation annotation : interfaceParamAnnotations) { if (annotation instanceof ApiParam) { apiParam = annotation; break; } } if (null == apiParam) { for (Annotation annotation : annotations) { if (annotation instanceof ApiParam) { apiParam = annotation; break; } } } } final Parameter parameter = readParam(context.getSwagger(), type,cls, null == apiParam ? null : (ApiParam) apiParam); if (parameter != null) { parameter.setName(null == name ? parameter.getName() : name); operation.parameter(parameter); } }
queryParameter.setRequired(BooleanUtils.toBoolean(requestParamAnnotationSource.getStringValue("required"))); setParameterType(parameterSource, queryParameter); operation.parameter(queryParameter); setParamDescription(parameterSource, methodParamDescriptions, queryParameter); bodyParameter.setRequired(true); bodyParameter.setSchema(new RefModel(name)); operation.parameter(bodyParameter); setParamDescription(parameterSource, methodParamDescriptions, bodyParameter); pathParameter.name(pathVariableAnnotationSource.getStringValue("value").trim()); setParameterType(parameterSource, pathParameter); operation.parameter(pathParameter); setParamDescription(parameterSource, methodParamDescriptions, pathParameter);
operation.parameter(v).parameter(q); operation.addResponse("200", new Response() .description(resourceName + " response") .schema(new RefProperty("#/definitions/FetchAll"))); if (((BaseDelegatingResource<?>) resourceHandler).hasTypesDefined()) { operation.parameter(subclassTypeParameter); operation.setSummary("Fetch all non-retired " + resourceName + " resources or perform search"); operation.setDescription("All search parameters are optional"); operation.parameter(q); operation.parameter(p);
.description(getDescription) .tag(getTag()) .parameter(getSparseFieldsParameter()) .parameter(getIncludeParameter()) .parameter(getSortParameter()) .response(200, okPluralResponse)); .tag(getTag()) .response(201, okSingularResponse) .parameter(new BodyParameter() .schema(new Datum(typeName)) .name(typeName))
.description("Returns an instance of type " + typeName) .tag(getTag()) .parameter(getSparseFieldsParameter()) .parameter(getIncludeParameter()) .response(200, okSingularResponse)); .tag(getTag()) .response(204, okEmptyResponse) .parameter(new BodyParameter() .schema(new Datum(typeName)) .name(typeName))
deleteOperation.parameter(purgeParam); } else {
output.parameter(convertParameter(parameter));
protected Operation generateEntityDeleteOperation(ModelImpl entityModel) { return new Operation() .tag(entityModel.getName()) .produces(APPLICATION_JSON_VALUE) .summary("Deletes the entity: " + entityModel.getName()) .parameter(new PathParameter() .name("entityId") .description("Entity identifier") .required(true) .property(new StringProperty())) .response(200, new Response().description("Success. Entity was deleted.")) .response(403, getErrorResponse("Forbidden. The user doesn't have permissions to delete the entity")) .response(404, getErrorResponse("Not found. MetaClass for the entity with the given name not found.")); }
protected Operation generateEntityReadOperation(ModelImpl entityModel) { Operation operation = new Operation() .tag(entityModel.getName()) .produces(APPLICATION_JSON_VALUE) .summary("Gets a single entity by identifier: " + entityModel.getName()) .description("Gets a single entity by identifier") .parameter(new PathParameter() .name("entityId") .description("Entity identifier") .required(true) .property(new StringProperty())) .response(200, new Response() .description("Success. The entity is returned in the response body.") .schema(new RefProperty(ENTITY_DEFINITION_PREFIX + entityModel.getName()))) .response(403, getErrorResponse("Forbidden. The user doesn't have permissions to read the entity.")) .response(404, getErrorResponse("Not found. MetaClass for the entity with the given name not found.")); operation.getParameters().addAll(generateEntityOptionalParams(true)); return operation; }
protected Operation generateEntityUpdateOperation(ModelImpl entityModel) { BodyParameter entityParam = new BodyParameter() .name("entityJson") .description("JSON object with the entity") .schema(new RefModel(ENTITY_DEFINITION_PREFIX + entityModel.getName())); entityParam.setRequired(true); PathParameter entityIdParam = new PathParameter() .name("entityId") .description("Entity identifier") .required(true) .property(new StringProperty().description("Entity identifier")); return new Operation() .tag(entityModel.getName()) .produces(APPLICATION_JSON_VALUE) .summary("Updates the entity: " + entityModel.getName()) .description("Updates the entity. Only fields that are passed in the JSON object " + "(the request body) are updated.") .parameter(entityIdParam) .parameter(entityParam) .response(200, new Response() .description("Success. The updated entity is returned in the response body.") .schema(new RefProperty(ENTITY_DEFINITION_PREFIX + entityModel.getName()))) .response(403, getErrorResponse("Forbidden. The user doesn't have permissions to update the entity.")) .response(404, getErrorResponse("Not found. MetaClass for the entity with the given name not found.")); }
protected Operation generateEntitySearchOperation(ModelImpl entityModel, RequestMethod method) { Operation operation = new Operation() .tag(entityModel.getName()) .produces(APPLICATION_JSON_VALUE) .summary("Find entities by filter conditions: " + entityModel.getName()) .description("Finds entities by filter conditions. The filter is defined by JSON object " + "that is passed as in URL parameter.") .response(200, new Response() .description("Success. Entities that conforms filter conditions are returned in the response body.") .schema(new ArrayProperty(new RefProperty(ENTITY_DEFINITION_PREFIX + entityModel.getName())))) .response(400, getErrorResponse("Bad request. For example, the condition value cannot be parsed.")) .response(403, getErrorResponse("Forbidden. The user doesn't have permissions to read the entity.")) .response(404, getErrorResponse("Not found. MetaClass for the entity with the given name not found.")); if (RequestMethod.GET == method) { QueryParameter parameter = new QueryParameter() .name("filter") .required(true) .property(new StringProperty().description("JSON with filter definition")); operation.parameter(parameter); } else { BodyParameter parameter = new BodyParameter() .name("filter") .schema(new ModelImpl() .property("JSON with filter definition", new StringProperty())); parameter.setRequired(true); operation.parameter(parameter); } operation.getParameters().addAll(generateEntityOptionalParams(false)); return operation; }
.tag(getTag()) .response(204, okEmptyResponse) .parameter(new BodyParameter() .schema(new Data(new Relationship(typeName))) .name("relationship")) .tag(getTag()) .response(204, okEmptyResponse) .parameter(new BodyParameter() .schema(new Data(new Relationship(typeName))) .name("relationship")) .tag(getTag()) .response(201, okPluralResponse) .parameter(new BodyParameter() .schema(new Data(new Relationship(typeName))) .name("relationship")) .tag(getTag()) .response(204, okEmptyResponse) .parameter(new BodyParameter() .schema(new Datum(new Relationship(typeName))) .name("relationship"))
protected Operation generateEntityCreateOperation(ModelImpl entityModel) { Operation operation = new Operation() .tag(entityModel.getName()) .produces(APPLICATION_JSON_VALUE) .summary("Creates new entity: " + entityModel.getName()) .description("The method expects a JSON with entity object in the request body. " + "The entity object may contain references to other entities.") .response(201, new Response() .description("Entity created. The created entity is returned in the response body.") .schema(new RefProperty(ENTITY_DEFINITION_PREFIX + entityModel.getName()))) .response(400, getErrorResponse("Bad request. For example, the entity may have a reference to the non-existing entity.")) .response(403, getErrorResponse("Forbidden. The user doesn't have permissions to create the entity.")) .response(404, getErrorResponse("Not found. MetaClass for the entity with the given name not found.")); BodyParameter entityParam = new BodyParameter() .name("entityJson") .description("JSON object with the entity") .schema(new RefModel(ENTITY_DEFINITION_PREFIX + entityModel.getName())); entityParam.setRequired(true); operation.parameter(entityParam); return operation; }