swagger-core icon indicating copy to clipboard operation
swagger-core copied to clipboard

@SecurityScheme requires #type when #ref is used

Open dansiviter opened this issue 3 years ago • 0 comments

It's not possible to define a reference with @SecurityScheme without also defining a type.

@SecurityScheme(ref = "another.yaml#/components/securitySchemes/blagh")  // <-- Compilation error

More strange is that #name can be null even though it's required at all times so it can be referred to by @SecurityRequirement. Therefore, this would render as:

components:
  securitySchemes:
    "":  # <-- indeterminable value, is that valid?
      $ref: 'another.yaml#/components/securitySchemes/blagh'

It is possible to use a SecuritySchemaType#DEFAULT value, but it's not clear if this is the correct usage:

@SecurityScheme(type = SecuritySchemaType.DEFAULT, ref = "another.yaml#/components/securitySchemes/blagh") 

Which would give:

components:
  securitySchemes:
    "":  # <-- indeterminable value, is that valid?
      type: ""
      $ref: 'another.yaml#/components/securitySchemes/blagh'

It appears OAI/OpenAPI-Specification#2064 shows how this should appear.

Therefore, I believe #name should have no default and be mandatory, and #type should default to SecuritySchemaType#DEFAULT.

dansiviter avatar Jan 25 '22 15:01 dansiviter