Class Components

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

public class Components extends OpenApiElement
Holds a set of reusable objects for different aspects of the OpenAPI Specification.

The Components Object holds a set of reusable objects that can be referenced from other parts of the API specification. This promotes reusability and reduces duplication by allowing common schemas, responses, parameters, and other objects to be defined once and referenced multiple times using the $ref syntax.

OpenAPI Specification:

The Components Object is composed of the following fields:

  • schemas (map of SchemaInfo) - Reusable schema definitions
  • responses (map of Response) - Reusable response definitions
  • parameters (map of Parameter) - Reusable parameter definitions
  • examples (map of Example) - Reusable example definitions
  • requestBodies (map of RequestBodyInfo) - Reusable request body definitions
  • headers (map of HeaderInfo) - Reusable header definitions
  • securitySchemes (map of SecuritySchemeInfo) - Reusable security scheme definitions
  • links (map of Link) - Reusable link definitions
  • callbacks (map of Callback) - Reusable callback definitions
Example:

// Create a Components object with reusable schemas Components components = new Components() .setSchemas( JsonMap.of( "Pet", new SchemaInfo() .setType("object") .setRequired("id", "name") .setProperties( JsonMap.of( "id", new SchemaInfo().setType("integer"), "name", new SchemaInfo().setType("string") ) ), "Error", new SchemaInfo() .setType("object") .setProperties( JsonMap.of( "code", new SchemaInfo().setType("integer"), "message", new SchemaInfo().setType("string") ) ) ) ); // These schemas can then be referenced: "#/components/schemas/Pet"

See Also: