Class SecurityRequirement

java.lang.Object
org.apache.juneau.bean.openapi3.OpenApiElement
org.apache.juneau.bean.openapi3.SecurityRequirement

public class SecurityRequirement extends OpenApiElement
Lists the required security schemes for this operation.
See Also:
  • Constructor Details

  • Method Details

    • copy

      Makes a copy of this object.
      Returns:
      A new copy of this object.
    • getRequirements

      Returns the security requirements map.
      Returns:
      The security requirements map.
    • setRequirements

      Sets the security requirements map.
      Parameters:
      value - The new value for this property.
      Returns:
      This object.
    • addRequirement

      public SecurityRequirement addRequirement(String schemeName, String... scopes)
      Adds a security requirement.
      Parameters:
      schemeName - The security scheme name. Must not be null.
      scopes - The required scopes. Must not be null.
      Returns:
      This object.
    • setApiKeyAuth

      Adds a security requirement for a scheme that doesn't use scopes.

      This is a convenience method for adding security schemes that don't use scopes, such as API keys, HTTP Basic authentication, or HTTP Bearer tokens. According to the OpenAPI specification, security schemes that don't use scopes should have an empty array as the value.

      This method is equivalent to calling addRequirement(schemeName) with no scopes.

      Example:

      // Add API key authentication requirement SecurityRequirement requirement = new SecurityRequirement() .setApiKeyAuth("api_key"); // Results in: { "api_key": [] }

      See Also:
      Parameters:
      schemeName - The security scheme name. Must not be null.
      Returns:
      This object.
    • get

      public <T> T get(String property, Class<T> type)
      Description copied from class: OpenApiElement
      Generic property getter.

      Can be used to retrieve non-standard Swagger fields such as "$ref".

      Overrides:
      get in class OpenApiElement
      Type Parameters:
      T - The datatype to cast the value to.
      Parameters:
      property - The property name to retrieve.
      type - The datatype to cast the value to.
      Returns:
      The property value, or null if the property does not exist or is not set.
    • set

      public SecurityRequirement set(String property, Object value)
      Description copied from class: OpenApiElement
      Generic property setter.

      Can be used to set non-standard Swagger fields such as "$ref".

      Overrides:
      set in class OpenApiElement
      Parameters:
      property - The property name to set. Must not be null.
      value - The new value for the property.
      Returns:
      This object
    • keySet

      public Set<String> keySet()
      Description copied from class: OpenApiElement
      Returns all the keys on this element.
      Overrides:
      keySet in class OpenApiElement
      Returns:
      All the keys on this element.
      Never null.
    • strict

      Description copied from class: OpenApiElement
      Sets strict mode on this bean.
      Overrides:
      strict in class OpenApiElement
      Returns:
      This object
    • strict

      Description copied from class: OpenApiElement
      Sets strict mode on this bean.
      Overrides:
      strict in class OpenApiElement
      Parameters:
      value - The new value for this property.
      Non-boolean values will be converted to boolean using Boolean.valueOf(value.toString()).
      Can be null (interpreted as false).
      Returns:
      This object