Class Operation

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

public class Operation extends OpenApiElement
Describes a single API operation on a path.

The Operation Object describes a single operation (such as GET, POST, PUT, DELETE) that can be performed on a path. Operations are the core of the API specification, defining what actions can be taken, what parameters they accept, and what responses they return.

OpenAPI Specification:

The Operation Object is composed of the following fields:

  • tags (array of string) - A list of tags for API documentation control
  • summary (string) - A short summary of what the operation does
  • description (string) - A verbose explanation of the operation behavior (CommonMark syntax may be used)
  • externalDocs (ExternalDocumentation) - Additional external documentation for this operation
  • operationId (string) - Unique string used to identify the operation
  • parameters (array of Parameter) - A list of parameters that are applicable for this operation
  • requestBody (RequestBodyInfo) - The request body applicable for this operation
  • responses (map of Response, REQUIRED) - The list of possible responses as they are returned from executing this operation
  • callbacks (map of Callback) - A map of possible out-of band callbacks related to the parent operation
  • deprecated (boolean) - Declares this operation to be deprecated
  • security (array of SecurityRequirement) - A declaration of which security mechanisms can be used for this operation
  • servers (array of Server) - An alternative server array to service this operation
Example:

// Create an Operation object for a GET endpoint Operation operation = new Operation() .setTags("pet") .setSummary("Find pets by status") .setDescription("Multiple status values can be provided with comma separated strings") .setOperationId("findPetsByStatus") .setParameters( new Parameter() .setName("status") .setIn("query") .setDescription("Status values that need to be considered for filter") .setRequired(true) .setSchema( new SchemaInfo().setType("string") ) ) .setResponses( JsonMap.of( "200", new Response() .setDescription("successful operation") .setContent( JsonMap.of( "application/json", new MediaType() .setSchema(new SchemaInfo().setType("array")) ) ) ) );

See Also:
  • Constructor Details

    • Operation

      public Operation()
      Default constructor.
    • Operation

      public Operation(Operation copyFrom)
      Copy constructor.
      Parameters:
      copyFrom - The object to copy.
  • Method Details

    • getTags

      public List<String> getTags()
      Returns the tags list.
      Returns:
      The tags list.
    • setTags

      public Operation setTags(List<String> value)
      Sets the tags list.
      Parameters:
      value - The new value for this property.
      Returns:
      This object.
    • setTags

      public Operation setTags(String... value)
      Sets the tags list.
      Parameters:
      value - The new value for this property.
      Returns:
      This object.
    • addTags

      public Operation addTags(String... values)
      Bean property appender: tags.

      A list of tags for API documentation control.

      Parameters:
      values - The values to add to this property.
      Ignored if null.
      Returns:
      This object.
    • addTags

      public Operation addTags(Collection<String> values)
      Bean property appender: tags.

      A list of tags for API documentation control.

      Parameters:
      values - The values to add to this property.
      Ignored if null.
      Returns:
      This object.
    • addParameters

      public Operation addParameters(Parameter... values)
      Bean property fluent setter: parameters.

      A list of parameters that are applicable for this operation.

      Parameters:
      values - The values to add to this property.
      Ignored if null.
      Returns:
      This object.
    • addParameters

      Bean property fluent setter: parameters.

      A list of parameters that are applicable for this operation.

      Parameters:
      values - The values to add to this property.
      Ignored if null.
      Returns:
      This object.
    • addResponse

      public Operation addResponse(String statusCode, Response response)
      Bean property fluent setter: responses.

      The list of possible responses as they are returned from executing this operation.

      Parameters:
      statusCode - The status code for the response.
      Must not be null.
      response - The response object.
      Must not be null.
      Returns:
      This object.
    • addCallback

      public Operation addCallback(String name, Callback callback)
      Bean property fluent setter: callbacks.

      A map of possible out-of band callbacks related to the parent operation.

      Parameters:
      name - The name of the callback.
      Must not be null.
      callback - The callback object.
      Must not be null.
      Returns:
      This object.
    • addSecurity

      Bean property fluent setter: security.

      A declaration of which security mechanisms can be used for this operation.

      Parameters:
      values - The values to add to this property.
      Ignored if null.
      Returns:
      This object.
    • addSecurity

      Bean property fluent setter: security.

      A declaration of which security mechanisms can be used for this operation.

      Parameters:
      values - The values to add to this property.
      Ignored if null.
      Returns:
      This object.
    • addServers

      public Operation addServers(Server... values)
      Bean property fluent setter: servers.

      An alternative server array to service this operation.

      Parameters:
      values - The values to add to this property.
      Ignored if null.
      Returns:
      This object.
    • addServers

      Bean property fluent setter: servers.

      An alternative server array to service this operation.

      Parameters:
      values - The values to add to this property.
      Ignored if null.
      Returns:
      This object.
    • getSummary

      public String getSummary()
      Returns the summary.
      Returns:
      The summary.
    • setSummary

      public Operation setSummary(String value)
      Sets the summary.
      Parameters:
      value - The new value for this property.
      Returns:
      This object.
    • getDescription

      Returns the description.
      Returns:
      The description.
    • setDescription

      Sets the description.
      Parameters:
      value - The new value for this property.
      Returns:
      This object.
    • getOperationId

      Returns the operation ID.
      Returns:
      The operation ID.
    • setOperationId

      Sets the operation ID.
      Parameters:
      value - The new value for this property.
      Returns:
      This object.
    • getExternalDocs

      Returns the external documentation.
      Returns:
      The external documentation.
    • setExternalDocs

      Sets the external documentation.
      Parameters:
      value - The new value for this property.
      Returns:
      This object.
    • getParameters

      Returns the parameters list.
      Returns:
      The parameters list.
    • getParameter

      public Parameter getParameter(String in, String name)
      Returns the parameter with the specified type and name.
      Parameters:
      in - The parameter in. Must not be null.
      name - The parameter name. Must not be null.
      Returns:
      The matching parameter, or null if not found.
    • setParameters

      Sets the parameters list.
      Parameters:
      value - The new value for this property.
      Returns:
      This object.
    • setParameters

      public Operation setParameters(Parameter... value)
      Sets the parameters list.
      Parameters:
      value - The new value for this property.
      Returns:
      This object.
    • getRequestBody

      Returns the request body.
      Returns:
      The request body.
    • setRequestBody

      Sets the request body.
      Parameters:
      value - The new value for this property.
      Returns:
      This object.
    • getResponses

      Returns the responses map.
      Returns:
      The responses map.
    • getResponse

      public Response getResponse(String status)
      Returns the response with the given status code.
      Parameters:
      status - The HTTP status code. Must not be null.
      Returns:
      The response, or null if not found.
    • getResponse

      public Response getResponse(int status)
      Returns the response with the given status code.
      Parameters:
      status - The HTTP status code.
      Returns:
      The response, or null if not found.
    • setResponses

      Sets the responses map.
      Parameters:
      value - The new value for this property.
      Returns:
      This object.
    • getCallbacks

      Returns the callbacks map.
      Returns:
      The callbacks map.
    • setCallbacks

      Sets the callbacks map.
      Parameters:
      value - The new value for this property.
      Returns:
      This object.
    • getDeprecated

      Returns the deprecated flag.
      Returns:
      The deprecated flag.
    • setDeprecated

      Sets the deprecated flag.
      Parameters:
      value - The new value for this property.
      Returns:
      This object.
    • getSecurity

      Returns the security requirements list.
      Returns:
      The security requirements list.
    • setSecurity

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

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

      public List<Server> getServers()
      Returns the servers list.
      Returns:
      The servers list.
    • setServers

      public Operation setServers(List<Server> value)
      Sets the servers list.
      Parameters:
      value - The new value for this property.
      Returns:
      This object.
    • setServers

      public Operation setServers(Server... value)
      Sets the servers list.
      Parameters:
      value - The new value for this property.
      Returns:
      This object.
    • copy

      public Operation copy()
      Creates a copy of this object.
      Returns:
      A copy of 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 Operation 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

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

      public Operation strict(Object value)
      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