op.description(description(route, op.getSummary()));
operation.summary(apiOperation.value()).description(apiOperation.notes());
operation.summary(apiOperation.value()).description(apiOperation.notes());
public void applyDescription(Operation operation, Method method) { final ApiOperation apiOperation = ReflectionUtils.getAnnotation(method, ApiOperation.class); if (apiOperation != null && StringUtils.isNotBlank(apiOperation.notes())) { operation.description(apiOperation.notes()); } }
@Override public void applyDescription(Operation operation, Method method) { final ApiOperation apiOperation = ReflectionUtils.getAnnotation(method, ApiOperation.class); if (apiOperation != null && StringUtils.isNotBlank(apiOperation.notes())) { operation.description(apiOperation.notes()); } operation.description(operation.getDescription() == null ? outputMethod(method) : (outputMethod(method) + operation.getDescription())); }
op.description(doc); });
.operationId(apiOperation.nickname()) .summary(apiOperation.value()) .description(apiOperation.notes()) .tags(Arrays.asList(operationTags));
output.description(value);
public SwaggerHelperOperationDescriptionGenerationTest(final String operationSummary, final String operationDescription, final String expectedName, final String expectedDescription) { operation = new Operation().description(operationDescription).summary(operationSummary); swagger = new Swagger().path("/test", new Path().get(operation)); expected = new OperationDescription(expectedName, expectedDescription); }
public SwaggerHelperOperationDescriptionGenerationTest(final String operationSummary, final String operationDescription, final String expectedName, final String expectedDescription) { operation = new Operation().description(operationDescription).summary(operationSummary); swagger = new Swagger().path("/test", new Path().get(operation)); expected = new OperationDescription(expectedName, expectedDescription); }
protected Operation generateQueryCountOperation(RestQueriesConfiguration.QueryInfo query, RequestMethod method) { Operation operation = new Operation() .tag(query.getEntityName() + " Queries") .produces(APPLICATION_JSON_VALUE) .summary("Return a number of entities in query result") .description("Returns a number of entities that matches the query. You can use the all keyword for " + "the queryNameParam to get the number of all available entities.") .response(200, new Response() .description("Success. Entities count is returned") .schema(new IntegerProperty().description("Entities count"))) .response(403, getErrorResponse("Forbidden. The user doesn't have permissions to read the entity.")) .response(404, getErrorResponse("MetaClass not found or query with the given name not found")); operation.setParameters(generateQueryOpParams(query, method, false)); return operation; }
.description(operation.getNotes()) .operationId(operation.getNickname());
protected Operation generateServiceMethodOp(String service, RestMethodInfo methodInfo, RequestMethod requestMethod) { Operation operation = new Operation() .tag(service) .produces(APPLICATION_JSON_VALUE) .summary(service + "#" + methodInfo.getName()) .description("Executes the service method. This request expects query parameters with the names defined " + "in services configuration on the middleware.") .response(200, new Response() .description("Returns the result of the method execution. It can be of simple datatype " + "as well as JSON that represents an entity or entities collection.") .schema(new StringProperty())) .response(204, new Response().description("No content. This status is returned when the service " + "method was executed successfully but returns null or is of void type.")) .response(403, getErrorResponse("Forbidden. The user doesn't have permissions to invoke the service method.")); operation.setParameters(generateServiceMethodParams(service, methodInfo, requestMethod)); return operation; }
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 generateEntityBrowseOperation(ModelImpl entityModel) { Operation operation = new Operation() .tag(entityModel.getName()) .produces(APPLICATION_JSON_VALUE) .summary("Gets a list of entities: " + entityModel.getName()) .description("Gets a list of entities") .response(200, new Response() .description("Success. The list of entities is returned in the response body.") .schema(new ArrayProperty(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.setParameters(generateEntityOptionalParams(false)); return operation; }
protected Operation generateQueryOperation(RestQueriesConfiguration.QueryInfo query, RequestMethod method) { Operation operation = new Operation() .tag(query.getEntityName() + " Queries") .produces(APPLICATION_JSON_VALUE) .summary(query.getName()) .description("Executes a predefined query. Query parameters must be passed in the request body as JSON map.") .response(200, new Response() .description("Success") .schema(new ArrayProperty(new RefProperty(ENTITY_DEFINITION_PREFIX + query.getEntityName())))) .response(403, getErrorResponse("Forbidden. A 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.setParameters(generateQueryOpParams(query, method, true)); return operation; }
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; }
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; }
.operationId(GET_NICKNAME) .summary(GET_VALUE) .description(GET_DESCRIPTION) .tags(expectedTags) .parameter(formParameter) .operationId(POST_NICKNAME) .summary(POST_VALUE) .description(POST_DESCRIPTION) .tags(expectedTags) .parameter(bodyParameter)
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.")); }