Is there a way to reference the component securityScheme from a common swagger definitions so I do not need to duplicate it in each of my swagger definitions? Like $ref http://somurl.com/component/securityScheme/oauthSample. If so what is the syntax to add this globally and per path?
security:
- oauthSample:
- read
- write
security:
- oAuthSample: [write]
You need to "import" the external security scheme definition into the "components/securitySchemes" section of the current file. Then you can define the global and path-level security requirements in the usual way.
components:
securitySchemes:
oauthSample:
$ref: 'http://somurl.com/component/securityScheme/oauthSample'
security:
- oauthSample:
- read
- write
Thanks for your response. Swagger is giving me an error saying it can not resolve the reference. I triple checked the path. I even tried adding a reference from the same file as the securitySchemes that I am using and that is not resolving for the securitySchemes.
Any other tips?
Which Swagger tool do you mean - Swagger Editor, Swagger UI, Swagger Codegen, ...?
I am not sure. It is an editor on https://app.swaggerhub.com/ where I am creating the API Yaml definitions.
Subject | Author | Latest Post |
---|---|---|