private Parameter buildRequiredUUIDParameter(String name, String desc) { return new PathParameter().name(name).description(desc).type("string"); }
/** * @return the swagger PathParameter for this particular path segment. */ private Parameter getPathParameter() { String typeName = dictionary.getJsonAliasFor(type); Parameter param = new PathParameter() .name(typeName + "Id") .description(typeName + " Identifier") .property(new StringProperty()); return param; }
/** * 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()); }
pm = new PathParameter().description("This is a MatrixParameter, which is not supported by Swagger. " + "Please add custom client code to pass the parameter properly.").items(new MapProperty(new StringProperty())).type(param.getType());
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.")); }
.description(PATH_PARAM_VALUE) .required(false) .type(SwaggerDocumentation.DataTypes.DATA_TYPE_STRING);