Although this is straying afield from the original question and from
Dropwizard: you'll probably want to dig into the implementation of the
swagger-ui pages. If memory serves there is an already-considered notion
of plugging in an API key somewhere in there. Nothing automagical really.
Internally we have doctored up Dropwizard's authentication system to allow
HTTP Basic auth only some of the time--yes on same-origin requests, no
otherwise mostly--which makes for a nice enough swagger-ui experience. In
the bigger picture it is quite useful to support basic, bearer token, SSL
client certificate, JWT, etc., under varying conditions.
On Friday, November 1, 2019 at 3:48:10 PM UTC-4, Jason Novotny wrote:
>
> Thanks Steve,
>
> I'm trying to get Swager UI to be usable-- here's my basic problem:
>
> 1. I have an endpoint called /auth/login.
>
> As you can see from the screenshot it works and it returns the token that
> is used in subsequent calls requiring authentication.
>
> 2. Given an API endpoint requiring authentication-- how can a Swagger UI
> user call this API? How to pass in the token from above?
>
> Thanks, Jason
> On 11/1/19 12:30 PM, Steve Kradel wrote:
>
> @ApiParam(hidden = true) will tell Swagger/OpenAPI not to include that
> parameter in the spec.
>
> On Friday, November 1, 2019 at 1:57:12 PM UTC-4, Jason Novotny wrote:
>>
>> Hi,
>>
>> Given an API requiring authentciation like so:
>>
>> @Path("/updateUser")@POSTpublic String updateUser(@Auth UserPrincipal
>> userPrincipal, UserRequest user)
>>
>> How do I add the appropriate annotations in Swagger so that a client can
>> test the API in the Swagger UI?
>>
>> What I currently get is the attached screenshot
>>
>> Thanks, Jason
>>
>> --
> You received this message because you are subscribed to a topic in the
> Google Groups "dropwizard-user" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/dropwizard-user/hH6R2544yaQ/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> [email protected] <javascript:>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/dropwizard-user/4a2c65ae-c52d-4575-9dc3-d71559a19659%40googlegroups.com
>
> <https://groups.google.com/d/msgid/dropwizard-user/4a2c65ae-c52d-4575-9dc3-d71559a19659%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
>
--
You received this message because you are subscribed to the Google Groups
"dropwizard-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/dropwizard-user/6d195cf1-728b-4bb1-92e5-7ba393dfa28e%40googlegroups.com.