Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple example values #36

Merged
merged 3 commits into from
Jan 3, 2021
Merged

Multiple example values #36

merged 3 commits into from
Jan 3, 2021

Conversation

lganzzzo
Copy link
Member

@lganzzzo lganzzzo commented Jan 3, 2021

Summary

Add example-values feature for RequestBody, Response, and Parameters (Path, Headers, Queries)

Add Consumes Examples

ENDPOINT_INFO(myEndpoint) {

  info->addConsumes<Object<MyDto>>("application/json")
    .addExample("example_1", MyDto::createShared(... /* params here */ ))
    .addExample("example_2", MyDto::createShared(... /* params here */ ))
    .addExample("example_3", MyDto::createShared(... /* params here */ ));

}

Add Response Examples

ENDPOINT_INFO(myEndpoint) {

  info->addResponse<Object<MyDto>>(Status::CODE_200, "application/json")
    .addExample("Successful Response_1", MyDto::createShared(... /* params */ ));

  info->addResponse<Object<ErrorDto>>(Status::CODE_404, "application/json")
    .addExample("Error - Not found", ErrorDto::createShared(404, "Not Found"));

  info->addResponse<Object<ErrorDto>>(Status::CODE_500, "application/json")
    .addExample("Error - DB Connection", ErrorDto::createShared(500, "Can't connect to DB"))
    .addExample("Error - Unknown", ErrorDto::createShared(500, "Unknown Error"));

}

Add Parameter Examples

ENDPOINT_INFO(myEndpoint) {

  info->pathParams["userRole"]
    .addExample("Admin", oatpp::Enum<UserRole>(UserRole::ADMIN))
    .addExample("Guest", oatpp::Enum<UserRole>(UserRole::GUEST));

}

@lganzzzo lganzzzo merged commit 8b70945 into master Jan 3, 2021
@lganzzzo lganzzzo deleted the multiple_example_values branch January 3, 2021 18:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant