oatpp / oatpp-swagger

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

Optional authentication #46

Open elgatito opened 2 years ago

elgatito commented 2 years ago

Hello,

I have optional authentication, implemented via request interceptor. So I added this to ENDPOINT_INFO:

        info->addSecurityRequirement("basic_auth");

But with this declaration I get runtime asserts because of missing AUTHENTICATION macro in the endpoint declaration.

That is expected behavior?

bamkrs commented 2 years ago

Hi @elgatito!

Yes, indeed. We do not have functionality for optional authentication currently. If you set an security requirement, the endpoint has authentication required. I did not recall swagger having optional authentication for an endpoint at the time of implementing this feature. We want to stick to the OAS-3.0.0/SWAGGER as closely as possible. Does OAS define optional authentication? If so we should find a solution for that!