Skip to content

When generating openapi spec, examples trait does not respect jsonName trait #2659

Open
@ingemaradahl

Description

@ingemaradahl

When using the converting Smithy to OpenAPI, generation of examples from the @examples documentation trait the @jsonName trait is not respected, leading to generation of examples which don't comply with the generated spec.

I adapted the quickstart-cli template project to showcase the problem: ingemaradahl/smithy-openapi-example@dfada35. The generated OpenAPI spec correctly uses the jsonName when generating the component schemas, but in the example uses the original smithy structure member name.

It is possible to use the same value as the jsonName trait argument in the example, but this leads to warnings issued when running smithy build. When incorporating in build tools, these warnings are sometimes treated as errors:

──  WARNING  ── ExamplesTrait.UnknownMember.example.weather#CityCoordinates.coordinate_system
Shape: example.weather#CreateCity
File:  models/weather.smithy:99:22

99|         coordinates: {
  |                      ^

Example input of Create a city.coordinates: Member coordinate_system does
not exist in example.weather#CityCoordinates

Metadata

Metadata

Assignees

No one assigned

    Labels

    OpenAPIbugThis issue is a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions