oatpp / oatpp-swagger

OpenApi 3.0.0 docs + Swagger UI for oatpp services
https://oatpp.io/
Apache License 2.0
95 stars 54 forks source link

Enum support #19

Closed cem closed 4 years ago

cem commented 4 years ago

Hi. Do you have any plans to support enum types?

lganzzzo commented 4 years ago

Hello @cem ,

Thanks for the question.

As I understand you are interested in adding enum with possible values for a parameter in swagger-UI. This must be pretty easy to implement via the additional endpoint info

something like:

ENDPOINT_INFO(getColor) {
  ...
  info->pathParams["color"].description = "Color name";
  info->pathParams["color"].enum = {"red", "green", "blue"};
}
ENDPOINT("GET", "/colors/{color}", getColor,
         PATH(String, color)) 
{
  mySelfWrittenColorParameterValidation(color); // manually implement color parameter validation.
  ...
}

As for the automatic validation of this parameter on the endpoint - it's something we need to investigate.


I'll add this to the scope - implement enum field for parameter in EndpointInfo

Regards, Leonid

lganzzzo commented 4 years ago

Hello @cem ,

The support for Enum is already added in the latest oatpp and oatpp-swagger.

Please see the oatpp changelog for details.

ENDPOINT("GET", "/colors/{color}", getColor,
         PATH(Enum<Color>, color))
{
  // No need to validate color values. All validations are already done.
  ...
}

Regards, Leonid