-
Notifications
You must be signed in to change notification settings - Fork 61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[PROPOSAL] Replace Smithy with a native OpenAPI spec #189
Comments
|
|
👍 to go OpenAPI full speed, Smithy gets its credits but the "recent" updates to OpenAPI spec (3.1) are buying us much more (specifically, JSON Schema support) |
Its sounds logical that we simply and write directly in OpenAPI.
I have encountered the two problems described above. It would be interesting to try writing directly into OpenAPI without the extra layer of Smithy. |
Just trying to understand that the issues we are facing currently with Smithy are entirely related to how Smithy works or are they because OpenSearch APIs are written in a certain way and we end up writing workarounds with OpenAPI as well? |
Of course we will lose out on the biggest perk that comes out of the box with Smithy: Organization of files. Like mentioned in the first bullet, OpenAPI does support that but we will have to be smart about it. I'm working on the Proof of Concept on how an editable pure OpenSearch API Spec would look like right now. |
Here's the POC Branch: https://github.com/opensearch-project/opensearch-api-specification/tree/feature/native_openapi Note that the POC spec are not the 1:1 translation from the current spec:
|
Looks good. Lowercase |
It looks good, I've had good success updating my Java codegen POC to operate off the split spec: opensearch-project/opensearch-java#366 Only issue to note is that at least in the case of the multi-file spec, Java/swagger-parser is unhappy with the
|
Ideas.
|
@Xtansia RE
|
@nhtruong for the |
@Xtansia I see. I'll convert all |
I understand. I think the question is really whether we check in the combined result or not. My initial thought is not because it's a generated file, but I don't feel that strongly about it.
I'm thinking a release process is more important, something we don't have today in this repo. For example, creating a semver-versioned tag would trigger a proper release like here.
My issue is simpler, https://github.com/opensearch-project/opensearch-api-specification/blob/feature/native_openapi/OpenSearch.openapi.yaml is huge and difficult to edit. Maybe it can be broken up into a file per path. |
That file you linked is not meant to be edited. The spec is split into smaller files in the spec folder: https://github.com/opensearch-project/opensearch-api-specification/tree/feature/native_openapi/spec The |
I see. That goes back to my other comment about checking in generated files. We should either remove those from the repo, or at least have a |
Here's the PR for the switch from Smithy to OpenAPI: #208. It's easier to review this PR like reviewing a new repo by inspecting the feature branch. We'll need to disable the
|
Closing this since #208 has already been merged. |
In the past discussions on Smithy vs OpenAPI [1] [2], we decided to have OpenAPI as the official spec of OpenSearch but use Smithy to describe the API as it's easier to organize:
After a year of going with this strategy, as we've learned a lot more about the quirks of OpenSearch API that are not compatible with Smithy's many guardrails, writing the spec in Smithy is becoming more challenging:
1. Smithy does not support certain data types for path and query-string parameters
Many OpenSearch operations have URL parameters that accepts either a single value as a string, an array of values separated by commas. That is, these parameters have
string | string[]
as data type. This can be described in Smithy as a union. However, Smithy doesn't allow unions in its URL parameters (It also doesn't allow arrays/lists in path parameters specifically).WORKAROUND: represent the data type as a string in Smithy but mark it with
xDataType('string | string[]')
. If the member of the list is not generic, we must also includexArrayItems('MemberName')
, andxEnum([...])
when applied.smithy-lang/smithy#2131
2. Smithy does not support untagged unions.
Only tagged unions are supported, which enforce a wrapping structure, while we have fields that are for example
int | boolean
. This would map to aoneOf
in OpenAPI.smithy-lang/smithy#2143
3. OpenSearch operations cause URI Conflict errors in Smithy
For example, since operations regarding an index or a list of indices have URI starting with
/{index}/...
, other operations, sayGET _cat/indices
, cause URL Conflict for Smithy as it sees_cat
as an{index}
parameter.WORKAROUND: Mark every operations with
@suppress(["HttpUriConflict"])
and every path parameter with@pattern("^(?!_|template|query|field|point|clear|usage|stats|hot|reload|painless).+$")
and@xPattern("")
smithy-lang/smithy#1539
4. Unable to customise inlining and
$ref
naming strategy in OpenAPI conversionIf we are able to customise this strategy we can stop certain “simple” types from always being inlined in the OpenAPI conversion, and we can implement a custom naming scheme for the $refs such that we can name them to match the ElasticSearch spec we inherit. (e.g.
#/components/schemas/_type:Duration
)smithy-lang/smithy#2144
5. Smithy mixins are always flattened/erased.
We’re unable to easily represent an inheritance hierarchy within Smithy that is translated to OpenAPI. Potential solution by introducing flag in translator that somehow retains mixins and puts them into
allOf
in OpenAPI.smithy-lang/smithy#2145
In short, Smithy, with its many guardrails, is unfit to describe OpenSearch API:
The many gotchas, and conventions we have to establish (as seen in the DEVELOPER_GUIDE) also deter people from contributing to this project. People maintaining this repo, on top of understanding OpenAPI, must also learn Smithy and the workarounds to make it work with OpenSearch API.
Given the difficulties in mapping OpenSearch's API to Smithy, I propose we instead maintain our API definitions directly in OpenAPI. Smithy a great tool for creating new APIs thanks to its many guardrails, but OpenSearch API has many unconventional traits that are simply incompatible with it.
The text was updated successfully, but these errors were encountered: