smithy/smithy-openapi-traits
Thomas Farr 0ce4187cb1
Support serializing traits into specification extensions in OpenAPI (#1609)
## `smithy.openapi#specificationExtension`

Adds a meta trait `smithy.openapi#specificationExtension` that can be used to annotate traits to indicate they should be serialized into specification extension (`x-*`) properties when converting to OpenAPI. This is supported on shapes, operations, and services. By default the extension will be named by the shape ID replacing `#` & `.` with `-` prefixed with `x-`, otherwise the extension can be specified using the `as` property.

A new package `smithy-openapi-traits` is introduced to contain the `smithy.openapi#specificationExtension` trait.

## `JsonSchemaMapper` and `JsonSchemaShapeVisitor`

BREAKING CHANGE: Technically, `JsonSchemaMapper` has a breaking change from a functional interface to a normal interface, but we are anticipating customers are not using `JsonSchemaMapper` as a functional interface since it was not annotated with `@FunctionalInterface`.

`JsonSchemaMapper` is updated to use `updateSchema(JsonSchemaMapperContext, Schema.Builder)` in `JsonSchemaShapeVisitor`, which will call the existing `updateSchema(Shape, Schema.Builder, JsonSchemaConfig)` by default when not implemented for backwards compatibility.

## `smithy-openapi`

Support is added for `smithy.openapi#specificationExtension` by implementing `SpecificationExtensionsMapper` for operations and services and updating `OpenApiJsonSchemaMapper` for shapes.

---------

Co-authored-by: Steven Yuan <yuasteve@amazon.com>
2023-08-16 12:11:20 -07:00
..
src/main Support serializing traits into specification extensions in OpenAPI (#1609) 2023-08-16 12:11:20 -07:00
build.gradle Support serializing traits into specification extensions in OpenAPI (#1609) 2023-08-16 12:11:20 -07:00