public final class Context<T extends Trait>
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
Schema |
createRef(ToShapeId shapeId)
Creates a schema that contains a $ref that points to a schema component.
|
java.util.Set<java.lang.String> |
getAllSecuritySchemeRequestHeaders()
Gets an alphabetically sorted set of request headers used by every
security scheme associated with the API.
|
java.util.Set<java.lang.String> |
getAllSecuritySchemeResponseHeaders()
Gets an alphabetically sorted set of response headers used by every
security scheme associated with the API.
|
OpenApiConfig |
getConfig()
Gets the configuration object used for the conversion.
|
JsonSchemaConverter |
getJsonSchemaConverter()
Gets the JSON schema converter.
|
Model |
getModel()
Gets the Smithy model being converted.
|
OpenApiProtocol<T> |
getOpenApiProtocol()
Gets the OpenAPI protocol conversion object.
|
java.lang.String |
getPointer(ToShapeId shapeId)
Gets the JSON pointer string to a specific shape.
|
T |
getProtocolTrait()
Gets the protocol trait that is being converted.
|
Schema |
getSchema(java.lang.String pointer)
Gets a converted schema from the context object by JSON pointer
and throws if the schema does not exist.
|
java.util.List<SecuritySchemeConverter<? extends Trait>> |
getSecuritySchemeConverters()
Gets the security scheme converters that are compatible with the
selected protocol.
|
ServiceShape |
getService()
Gets the service shape being converted.
|
java.util.Map<java.lang.String,Schema> |
getSynthesizedSchemas()
Gets all of the synthesized schemas that needed to be created while
generating the OpenAPI artifact.
|
Schema |
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.
|
java.lang.String |
putSynthesizedSchema(java.lang.String name,
Schema schema)
Puts a new synthesized schema that is needed to convert to OpenAPI.
|
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.
|
public Model getModel()
public ServiceShape getService()
public OpenApiConfig getConfig()
Plugins can query this object for configuration values.
public JsonSchemaConverter getJsonSchemaConverter()
public T getProtocolTrait()
public OpenApiProtocol<T> getOpenApiProtocol()
public Schema getSchema(java.lang.String pointer)
pointer
- Schema to retrieve by JSON pointer (e.g., "#/components/schemas/foo").OpenApiException
- if the schema cannot be found.public java.lang.String getPointer(ToShapeId shapeId)
shapeId
- Shape ID to convert into a JSON pointer to a schema component.public Schema createRef(ToShapeId shapeId)
shapeId
- Shape ID to point to with a $ref schema.public Schema inlineOrReferenceSchema(MemberShape member)
member
- Member to inline or reference.public java.util.List<SecuritySchemeConverter<? extends Trait>> getSecuritySchemeConverters()
public boolean usesHttpCredentials()
This is useful when integrating with things like CORS.
public java.util.Set<java.lang.String> getAllSecuritySchemeRequestHeaders()
This is useful when integrating with things like CORS.
public java.util.Set<java.lang.String> getAllSecuritySchemeResponseHeaders()
This is useful when integrating with things like CORS.
public java.util.Map<java.lang.String,Schema> getSynthesizedSchemas()
public java.lang.String putSynthesizedSchema(java.lang.String name, Schema schema)
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.
name
- Name of the schema to put into components/schemas. Nested
pointers are not supported.schema
- The schema to put.