/** * @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; }
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.")); }