Skip to content

Commit

Permalink
Support recursive requests for schemas
Browse files Browse the repository at this point in the history
  • Loading branch information
Gaute Lindkvist committed Mar 14, 2024
1 parent 30d76ee commit 12b2bff
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion RestInterface/cafRestOpenApiService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,24 @@ RestServiceInterface::ServiceResponse RestOpenApiService::perform( http::verb
{
return std::make_tuple( http::status::bad_request, "Only GET requests are allowed for api queries", nullptr );
}
CAFFA_ASSERT( !path.empty() );
path.pop_front();

return std::make_tuple( http::status::ok, getOpenApiV31Schema().dump(), nullptr );
auto currentSchema = getOpenApiV31Schema();

for ( auto currentPathEntry : path )
{
if ( currentSchema.contains( currentPathEntry ) )
{
currentSchema = currentSchema[currentPathEntry];
}
else
{
return std::make_tuple( http::status::not_found, "Entry " + currentPathEntry + " not found", nullptr );
}
}

return std::make_tuple( http::status::ok, currentSchema.dump(), nullptr );
}

bool RestOpenApiService::requiresAuthentication( http::verb verb, const std::list<std::string>& path ) const
Expand Down

0 comments on commit 12b2bff

Please sign in to comment.