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

fix referenced components removed in openapi schema #1595

Merged
merged 1 commit into from
Feb 17, 2023

Conversation

AndrewFossAWS
Copy link
Contributor

Issue #, if available:

Customer reported referenced component being removed in openapi schema.

In RemoveUnusedComponents, it only keeps referenced components if the field object size is 1.

However there are cases where the field object size is greater than 1.

For example:

smithy:

structure OperationInput {
    @default({})
    payload: StringMap
}

map StringMap {
    key: String
    value: String
}

openapi:

(StringMap is removed in the schemas object.)

    "schemas": {
        "OperationRequestContent": {
            "properties": {
                "payload": {
                    "$ref": "#/components/schemas/StringMap",
                    "default": {}
                }
            }
        }
    }

Description of changes:

Remove the field object size check when removing unused components

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

@AndrewFossAWS AndrewFossAWS requested a review from a team as a code owner January 26, 2023 19:13
@mtdowling
Copy link
Member

I didn't think $ref objects allowed more than one property. Can you confirm?

@AndrewFossAWS
Copy link
Contributor Author

I didn't think $ref objects allowed more than one property. Can you confirm?

@mtdowling From the reference object section of the OpenAPI spec:

This object cannot be extended with additional properties and any properties added SHALL be ignored.

So default property will be ignored in my example.
I was able to deploy an openapi json with the additional property default to API Gateway. The default property was ignored/removed.

I can add a WARN log to let users know the additional properties will be ignored.

@mtdowling
Copy link
Member

Thanks. Warning would be too noisy here since it looks like we add default values to these refs automatically.

@AndrewFossAWS AndrewFossAWS merged commit 53ea409 into smithy-lang:main Feb 17, 2023
@AndrewFossAWS AndrewFossAWS deleted the openapi-fix branch September 21, 2023 21:46
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.

2 participants