Skip to content
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

Define trait and extension for adding x- properties to openapi output #73

Merged
merged 2 commits into from
Apr 11, 2023

Conversation

Xtansia
Copy link
Collaborator

@Xtansia Xtansia commented Feb 8, 2023

Description

Defines a custom trait and extension to the OpenAPI converter, to allow adding x- properties to schemas and operations in the OpenAPI output.

For example:

use opensearch.openapi#vendorExtensions

// ...
@vendorExtensions(
    "x-namespace": "cat"
    "x-operation": "indices"
)
operation GetCatIndices {
    input: GetCatIndicesInput,
    output: GetCatIndicesOutput
}

Results in:

          "/_cat/indices": {
            "get": {
                "description": "Returns information about indices: number of primaries and replicas, document counts, disk size, etc.",
                "operationId": "GetCatIndices",
                "parameters": [ ... ],
                "responses": {
                    "200": { ... }
                },
                "x-namespace": "cat",
                "x-operation": "indices"
            }
        },

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

@nhtruong
Copy link
Collaborator

nhtruong commented Feb 8, 2023

instead of extendedMetadata can it be renamed to openApiExtensions to clarify the purpose and lock down the scope of this trait?

@reta
Copy link
Contributor

reta commented Feb 8, 2023

instead of extendedMetadata can it be renamed to openApiExtensions to clarify the purpose of this trait?

Or vendorExtensions [1], quite often used

[1] https://swagger.io/docs/specification/openapi-extensions/

@nhtruong
Copy link
Collaborator

nhtruong commented Feb 8, 2023

Or vendorExtensions [1], quite often used

[1] https://swagger.io/docs/specification/openapi-extensions/

or openApiVendorExtensions (a bit long haha) since, in the context of Smithy, this trait is meant for OpenApi Extentions compatibility and has nothing to do with Smithy itself. We need OpenApi in the name for clarity.

@Xtansia Xtansia force-pushed the feat/openapi/x-props branch from 245b365 to 418a025 Compare February 8, 2023 20:19
@@ -7,6 +7,8 @@
$version: "2"
namespace OpenSearch

use opensearch.openapi#openApiVendorExtensions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nhtruong sorry, just want to hear your thoughts since Smithy is not my thing, BUT wouldn't use opensearch.openapi# already imply that those are vendor extensions for OpenAPI?

use opensearch.openapi#vendorExtensions

That would be pretty clean, no?

@Xtansia Xtansia force-pushed the feat/openapi/x-props branch from 418a025 to 9f4dd74 Compare February 8, 2023 20:43
@harshavamsi
Copy link
Collaborator

@Xtansia @nhtruong for the sake of clarity could you explain why adding x- to the model for OpenAPI is required? Is this something OpenAPI codegen requires to understand namespaces?

VachaShah
VachaShah previously approved these changes Apr 10, 2023
Copy link
Collaborator

@VachaShah VachaShah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Is this something we can document may be in this repo's developer guide?

Xtansia added 2 commits April 11, 2023 12:05
…tput

Signed-off-by: Thomas Farr <tsfarr@amazon.com>
Signed-off-by: Thomas Farr <tsfarr@amazon.com>
@VachaShah VachaShah merged commit 7bcae6c into opensearch-project:main Apr 11, 2023
@Xtansia Xtansia deleted the feat/openapi/x-props branch May 16, 2023 23:32
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.

5 participants