Class Context<T extends Trait>
-
Method Summary
Modifier and TypeMethodDescriptionCreates a schema that contains a $ref that points to a schema component.Gets an alphabetically sorted set of request headers used by every security scheme associated with the API.Gets an alphabetically sorted set of response headers used by every security scheme associated with the API.Gets the configuration object used for the conversion.Gets the JSON schema converter.getModel()
Gets the Smithy model being converted.Gets the OpenAPI protocol conversion object.getPointer
(ToShapeId shapeId) Gets the JSON pointer string to a specific shape.Gets the protocol trait that is being converted.Gets a converted schema from the context object by JSON pointer and throws if the schema does not exist.List<SecuritySchemeConverter<? extends Trait>>
Gets the security scheme converters that are compatible with the selected protocol.Gets the service shape being converted.Gets all of the synthesized schemas that needed to be created while generating the OpenAPI artifact.inlineOrReferenceSchema
(MemberShape member) Gets the exiting schema of the shape if it's meant to be inlined, otherwise creates a $ref to the shape if it is meant to be reused across the generated schema.putSynthesizedSchema
(String name, Schema schema) Puts a new synthesized schema that is needed to convert to OpenAPI.boolean
Reports if any authentication mechanisms in the entire model use HTTP credentials, such as cookies, browser-managed usernames and passwords, or TLS client certificates.
-
Method Details
-
getModel
Gets the Smithy model being converted.- Returns:
- Returns the Smithy model.
-
getService
Gets the service shape being converted.- Returns:
- Returns the service shape.
-
getConfig
Gets the configuration object used for the conversion.Plugins can query this object for configuration values.
- Returns:
- Returns the configuration object.
-
getJsonSchemaConverter
Gets the JSON schema converter.- Returns:
- Returns the JSON Schema converter.
-
getProtocolTrait
Gets the protocol trait that is being converted.- Returns:
- Returns the protocol ID.
-
getOpenApiProtocol
Gets the OpenAPI protocol conversion object.- Returns:
- Returns the OpenAPI protocol.
-
getSchema
Gets a converted schema from the context object by JSON pointer and throws if the schema does not exist.- Parameters:
pointer
- Schema to retrieve by JSON pointer (e.g., "#/components/schemas/foo").- Returns:
- Returns the found schema.
- Throws:
OpenApiException
- if the schema cannot be found.
-
getPointer
Gets the JSON pointer string to a specific shape.- Parameters:
shapeId
- Shape ID to convert into a JSON pointer to a schema component.- Returns:
- Returns the JSON pointer to this shape as a schema component.
-
createRef
Creates a schema that contains a $ref that points to a schema component.- Parameters:
shapeId
- Shape ID to point to with a $ref schema.- Returns:
- Returns the creates schema.
-
inlineOrReferenceSchema
Gets the exiting schema of the shape if it's meant to be inlined, otherwise creates a $ref to the shape if it is meant to be reused across the generated schema.- Parameters:
member
- Member to inline or reference.- Returns:
- Returns the schema for the member.
-
getSecuritySchemeConverters
Gets the security scheme converters that are compatible with the selected protocol.- Returns:
- Returns the security scheme converters.
-
usesHttpCredentials
public boolean usesHttpCredentials()Reports if any authentication mechanisms in the entire model use HTTP credentials, such as cookies, browser-managed usernames and passwords, or TLS client certificates.This is useful when integrating with things like CORS.
- Returns:
- Whether any authentication mechanism relies on browser-managed credentials.
- See Also:
-
getAllSecuritySchemeRequestHeaders
Gets an alphabetically sorted set of request headers used by every security scheme associated with the API.This is useful when integrating with things like CORS.
- Returns:
- Returns the set of every request header used by every security scheme.
-
getAllSecuritySchemeResponseHeaders
Gets an alphabetically sorted set of response headers used by every security scheme associated with the API.This is useful when integrating with things like CORS.
- Returns:
- Returns the set of every response header used by every security scheme.
-
getSynthesizedSchemas
Gets all of the synthesized schemas that needed to be created while generating the OpenAPI artifact.- Returns:
- Returns the "synthesized" schemas as an immutable map.
-
putSynthesizedSchema
Puts a new synthesized schema that is needed to convert to OpenAPI.Synthesized schemas are used when ad-hoc schemas are necessary in order to materialize some change in OpenAPI while still providing an explicit name. For example, when generating many of the RESTful protocols, members from the input of an operation might come together to form the payload of a request. In Smithy, it's fine to use only part of the input to derive the payload, whereas in OpenAPI, you need a schema that's dedicated to the payload.
The primary alternative to synthesized schemas is inlined schema definitions. The problem with inline schemas is that they don't have an explicit or even deterministic name when used with other platforms (for example, API Gateway will generate a random name for an object if one is not given).
This method is thread-safe.
- Parameters:
name
- Name of the schema to put into components/schemas. Nested pointers are not supported.schema
- The schema to put.- Returns:
- Returns a JSON pointer to the created schema.
-