Open
Conversation
added 11 commits
June 15, 2022 15:21
Collaborator
|
Hi, thanks for working on this. Please be mindful that the current support is for openapi2/swagger. The openapi3 support that we have atm is simply a conversion from 2. Therefore the only supported types are: Currently we'd use jwt as an apiKey, example: #[derive(Apiv2Security, Deserialize)]
#[openapi(
apiKey,
alias = "JWT",
in = "header",
name = "Authorization",
description = "Use format 'Bearer TOKEN'"
)]
pub struct BearerToken;So, I think we can adapt your changes by adding your purposed changes by adding another field to the openapi2 SecuritySchema that is not serializable (as we don't want it to be present if we're generating openapi2 spec), but that allows us to convert to openapi3. And maybe for those types of things we'd have an |
04a5510 to
33cd55f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I needed to use an Authorization of type
apiKeyinheader.But the code that handled that was unreachable due to some conditions to build bearer auth in priority.
According to OAS3 (https://swagger.io/docs/specification/authentication/bearer-authentication/) :
basicAuth should use associations :
type: httpandscheme: basic.bearerAuth should use associations :
type: http, thescheme: bearerand if neededbearerFormat: JWT.ApiKeyAuth should use associations :
type: apiKey,in: headerandname: X-API-KEY.cookieAuth should use associations :
type: apiKey,in: cookieandname: JSESSIONID.I adapted the code so we could use all those authentication and fixed the comment standing there :
// how to determine when it should be JWT?.I completed the documentation page and added a test.
Bearer auth
apiKey auth