Skip to content

Add OpenAPI option to use operation input and output schema names - #3182

Open
arnabnandy7 wants to merge 2 commits into
smithy-lang:mainfrom
arnabnandy7:feature/retainOpStructure
Open

arnabnandy7 wants to merge 2 commits into
smithy-lang:mainfrom
arnabnandy7:feature/retainOpStructure

Conversation

@arnabnandy7

Copy link
Copy Markdown

Background

  • Adds an opt-in OpenAPI setting, useOperationInputOutputShapeNames, to name synthesized operation request and response content schemas after the Smithy input/output structures when possible.
  • This lets generated OpenAPI use component names like DoSomethingInput and DoSomethingOutput instead of DoSomethingRequestContent and DoSomethingResponseContent.
  • The existing naming behavior remains the default. If an operation reuses the same structure for both input and output, the converter falls back to the existing suffix-based names to avoid component collisions.
  • This is important for OpenAPI consumers and code generators that depend on stable schema names matching the original Smithy operation structures.

Testing

  • Ran ./gradlew :smithy-openapi:spotlessApply --no-daemon --max-workers=1
  • Ran ./gradlew :smithy-openapi:test --tests software.amazon.smithy.openapi.fromsmithy.protocols.AwsRestJson1ProtocolTest --tests software.amazon.smithy.openapi.fromsmithy.OpenApiConfigTest -PnoFormat --no-daemon --max-workers=1

Links


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@arnabnandy7
arnabnandy7 requested a review from a team as a code owner June 19, 2026 21:28
@arnabnandy7
arnabnandy7 requested a review from yasmewad June 19, 2026 21:28
…94761c41.json

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@JordonPhillips

Copy link
Copy Markdown
Contributor

Can I ask what the need for this is?

One reason why we don't do this is that these OpenAPI structures actually don't match the IO shapes, just the body content. Headers, uri params, and query params are all separate. So if you're trying to map the Smithy structures to the OpenAPI structures, a simple name mapping isn't going to work regardless.

@arnabnandy7

Copy link
Copy Markdown
Author

Can I ask what the need for this is?

Thanks for the feedback, @JordonPhillips.

The motivation comes from the original issue #2469 downstream OpenAPI consumers and code generators that use the schema component names as stable identifiers. When the synthesised names are DoSomethingRequestContent / DoSomethingResponseContent, those names carry no direct relationship to the Smithy model's DoSomethingInput / DoSomethingOutput shapes, making traceability harder.

You're right that the OpenAPI body-content schema is not a 1:1 mirror of the Smithy IO shape; headers, URI params, and query params are stripped out. This PR doesn't claim otherwise; the option is purely about naming the synthesised body-content schema after the original IO shape (when there's no collision), not about structural equivalence. The intent is that downstream consumers get a predictable, model-traceable name rather than a generated suffix.

That said, if there's a concern that this naming could mislead consumers into assuming structural equivalence, I'm happy to add explicit documentation/javadoc on the option, warning about this distinction.

Is there an approach you'd recommend instead to surface stable, model-traceable names for the synthesised body schemas? Happy to revise the implementation based on your guidance.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Retain operation input/output structure symbol (or allow customization) upon conversion to OpenAPI

2 participants