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

Replace swagger-cli with go-swagger. #457

Merged

Conversation

NullHypothesis
Copy link
Contributor

@NullHypothesis NullHypothesis commented May 22, 2024

This PR replaces the swagger-cli-based Azure pipeline with a go-swagger-based GitHub workflow. Ever since Nov 2023, swagger-cli is archived and the pipeline failed to catch a schema issue that I ran into while using go-swagger. We appear to be using go-swagger to generate Cloud-UI's and Cloud-REST's model files, so we should use the very same tool to validate the spec. It remains a mystery why swagger-cli and go-swagger disagree on what constitutes a valid spec.

@NullHypothesis NullHypothesis force-pushed the phw/sc-47949/bring-openapi-spec-and-models-back-in-sync branch from acc66bc to 488e21f Compare May 22, 2024 18:34
This PR replaces the swagger-cli-based Azure pipeline with a
go-swagger-based GitHub workflow.  Ever since Nov 2023, swagger-cli is
archived and the pipeline failed to catch a schema issue that I ran into
while using go-swagger.  We appear to be using go-swagger to generate
Cloud-UI's and Cloud-REST's model files, so we should use the very same
tool to validate the spec files.
When building models or validating the spec, go-swagger would fail with
the following error:

    $ swagger validate openapi-v1.yaml
    [...]
    The swagger spec at "openapi-v1.yaml" is invalid against swagger specification 2.0.
    See errors below:
    - "paths./invitations/share_payment/{namespace}.post.parameters" must validate one and only one schema (oneOf). Found none valid
    - paths./invitations/share_payment/{namespace}.post.parameters.schema in body is a forbidden property
    - paths./invitations/share_payment/{namespace}.post.parameters.in in body should be one of [header]
    - paths./invitations/share_payment/{namespace}.post.parameters.type in body should be one of [string number boolean integer array]
    - "/invitations/share_payment/{namespace}.POST.parameters.email_invite" must validate one and only one schema (oneOf). Found none valid
    - /invitations/share_payment/{namespace}.POST.parameters.email_invite.schema in body is a forbidden property
    - /invitations/share_payment/{namespace}.POST.parameters.email_invite.type in body should be one of [string number boolean integer array]
    - /invitations/share_payment/{namespace}.POST.parameters.email_invite.in in body should be one of [header]
@NullHypothesis NullHypothesis force-pushed the phw/sc-47949/bring-openapi-spec-and-models-back-in-sync branch from 4ca0945 to 75fc522 Compare May 22, 2024 18:55
@NullHypothesis NullHypothesis marked this pull request as ready for review May 22, 2024 18:57
@NullHypothesis NullHypothesis changed the title Add validation workflow. Replace swagger-cli with go-swagger. May 22, 2024
go-version: ${{ env.GO_VERSION }}

- name: Install go-swagger
run: go install github.com/go-swagger/go-swagger/cmd/swagger@latest
Copy link
Contributor

Choose a reason for hiding this comment

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

it might be worth specifying an exact version here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point – fixed in fa19c9e.

This prevents the workflow from mysteriously failing some time in the
future due to backward-incompatible changes.

Thanks to Paul for pointing this out.
@NullHypothesis NullHypothesis merged commit 7b61c09 into master May 22, 2024
1 check passed
@NullHypothesis NullHypothesis deleted the phw/sc-47949/bring-openapi-spec-and-models-back-in-sync branch May 22, 2024 22:17
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.

3 participants