Skip to content
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

Possible to use $ref in security and securityDefinitions? #846

Closed
atdiff opened this issue Nov 18, 2016 · 3 comments
Closed

Possible to use $ref in security and securityDefinitions? #846

atdiff opened this issue Nov 18, 2016 · 3 comments
Labels
re-use: ref-everywhere Requests to support referencing in more / all places security: config The mechanics of severs and structure of security-related objects security

Comments

@atdiff
Copy link

atdiff commented Nov 18, 2016

For large API structures, it makes sense to have API and definitions split out into multiple files for reuse and readability. Both security and securityDefinitions seem like properties that would benefit from leveraging the use of $ref. This way security info can be shared across multiple swagger files for one application.
Is it currently possible and are there examples of how to do it? I've tried multiple ways of defining the structure and nothing seems to work/get validated.

@radj
Copy link

radj commented Jan 16, 2018

This is especially applicable when the scopes are the same in many path+operation permutations.

Just in case anyone stumbles into this, a workaround can be found here.

@handrews handrews added the $ref label Feb 24, 2020
@dosvath
Copy link

dosvath commented Apr 15, 2022

If it helps anyone, we got the following to work in a file that references shared security settings:

components:
  securitySchemes:
    Basic_Authentication:
      $ref: 'https://your-public-url/auth.yml#/components/securitySchemes/Basic_Authentication'

and then defining

security:
  - Basic_Authentication: []

right before paths: . This is not the same as the securityDefinitions but it may help in cases like basic and bearer auth.

@handrews handrews added security re-use re-use: ref-everywhere Requests to support referencing in more / all places security: config The mechanics of severs and structure of security-related objects and removed $ref labels Jan 29, 2024
@handrews
Copy link
Member

Closing this for the same reason as #680:

This is about a structure in 2.0 that is no longer relevant. Security Schemes have been in the Components Object since 3.0, and see

for more recent similar requests. Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
re-use: ref-everywhere Requests to support referencing in more / all places security: config The mechanics of severs and structure of security-related objects security
Projects
None yet
Development

No branches or pull requests

4 participants