-
Notifications
You must be signed in to change notification settings - Fork 63
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
X-API-KEY header is not being attached via swagger UI #264
Comments
Hi @JPStrydom, The By default all configured security definitions from Just for completeness, to define the security schemes used, the "overriding" logic of Reference in the examples: feathers-swagger/example/openapi-v3/security.js Lines 44 to 51 in 657ab29
|
@Mairu You absolute beauty! That did the trick, thank you very much. Is there a way I can define this globally so that it applies to all requests? |
As there is no defaults option for securities the only way currently should be by setting it with So it should be possible to add that in your
|
Regarding the bonus question, yes the tagging is used for grouping, so you have to use the same tag for things that should "belong" together. |
Thanks so much for all the help @Mairu ! One last question: Is there any way to update how the URL's are encoded by Swagger? Now that my requests are working, it looks like Swagger is encoding some of my queries in an incompatible way. The following query, for example: {
"$sort": {
"id": 1,
"apiKey": 1
}
} Get's encoded to {
"name": "BadRequest",
"message": "validation failed",
"code": 400,
"className": "bad-request",
"data": [
{
"instancePath": "/$sort",
"schemaPath": "#/properties/%24sort/type",
"keyword": "type",
"params": {
"type": "object"
},
"message": "must be object"
}
]
} When querying through Postman with Is there any way I can update how Swagger encodes URLs? From my research it seems like adding a |
I think the encoding is correct, and the handling of these query parameters should be addressed in feathers instead. Check https://feathersjs.com/help/faq.html#why-are-queries-with-arrays-failing of how to adjust the query parameters parsing in feathers. If you still want to adjust the swagger config checkout https://github.com/Mairu/feathersjs-swagger-tests/blob/feathers-v5-koa-typebox/src/openapi.ts to see how to adjust the SwaggerUI configuration with feathers-swagger. |
Mhhhh doesn't seem like that works when using Koa, but I'll dig into how this can be done with Koa. Sure it should also be possible. |
I'm following Feather's API key auth strategy as listed here. My application only has API key auth and no other auth stratagies.
I've set up my API key to be read from the header field
x-api-key
and when running through Postman, the API key auth works as expected. With a correctx-api-key
field in a request header, the request authenticates as expected.I'm struggling to get the Swagger UI to send the header through, even though it looks like it's configured correctly.
My authentication is set up like this:
My Swagger instance is configured like this:
These are then configured in my
app.js
file like so:My endpoints are each configures like this:
In the Swagger UI, I can see the correct authentication UI:
But when making requests whilst authentication, the header doesn't appear to be attached to the request:
I've tried setting cors in my
app.js
like so, but thex-api-key
request header is still not being set:Does anyone know what I'm missing? Would really like to be able to test the API via the Swagger UI.
Bonus question: Is there a way I could have my sub-endpoints (
/api/
,/commands/
,/subscriptions/
) grouped together in Swagger UI, so that I could collapse them independently? I've tried using tags, but these set all the/api/
endpoints under one tagThe text was updated successfully, but these errors were encountered: