/** * Build a {@link PathParameter} Swagger object defined by {@link ApiImplicitParam} * to use for documentation. * * @param apiParam The annotation which documents the parameter. * @return The {@link PathParameter} object to be used in {@link Swagger} */ public static PathParameter pathParameter(ApiImplicitParam apiParam) { return new PathParameter() .name(apiParam.name()) .description(apiParam.value()) .required(apiParam.required()) .type(apiParam.dataType()); }
io.swagger.models.parameters.Parameter pm = null; if (RestRequestProcessor.isPathParameter(rm.fn, pName)) { pm = new PathParameter().type(param.getType()).required(true); } else { String aType = RestRequestProcessor.getParamAnnotationType(rm.fn, pName);
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.")); }
.name(PATH_PARAM_NAME) .description(PATH_PARAM_VALUE) .required(false) .type(SwaggerDocumentation.DataTypes.DATA_TYPE_STRING);