Alfred
Alfred

Reputation: 23

Using one OpenAPI file with Redoc -> restrict sections based on user role

I can't quite seem to find a solution to this..

Let's say we have one OpenAPI description that is loaded via Redoc standalone.

Is there anyway to show only specific parts based on a logged in role?

The logged in account being a php server with certain roles we can create.

Right now we basically have duplicated api documents to do this, but it would make more sense to have one single api document, and somehow be able to show specific api calls to the logged in user.

That way we're not creating multiple api documents for each role.

Upvotes: 0

Views: 301

Answers (1)

Lorna Mitchell
Lorna Mitchell

Reputation: 1996

Redoc doesn't have this functionality, but publishing multiple documents and serving the right one to the user is a good approach. Instead of maintaining multiple OpenAPI documents, work on one with everything in it, and use the filters at publish time to produce the separate API descriptions, and generate documentation from those.

(h/t @jeremy-fiel whose comment suggested this also)

Upvotes: 0

Related Questions