Skip to content

Remove use of "go-swagger" fork, and update to current version #42593

@thaJeztah

Description

@thaJeztah

related to #36714

We currently use go-swagger for two purposes:

  1. to validate the swagger file (against the swagger/openapi specs)
  2. to generate some Go types from the swagger YAML, and to validate that (generated) types match the definition in the swagger file (see Add swagger.yaml and generate a few types from the spec #27117)

For 1., we should be able to switch to use upstream/latest. However, for 2., things are more "complicated"; our code depends on a feature in go-swagger (see go-swagger/go-swagger#676, go-swagger/go-swagger#680) that was removed (or refactored/changed) go-swagger/go-swagger#2077. For our purpose we only want to generate some types from the Swagger file, and not generate other code (i.e., we don't want it to generate a full client);
Given that the feature was removed (or at least, no longer works with how we call it), we are currently not able to update go-swagger (for 2.). Unfortunately, the version we rely on has some issues;

  • compatibility with recent go versions broke (forcing us to use a fork of go-swagger, in which we maintain patches)
  • the version we use has a bug; when generating types, the order in which fields end up in the generated code is randomized (due to some code in go-swagger iterates over map[string] which (by design) is randomized by golang). This causes CI to be "flaky" (swagger validation randomly failing if changes are made to the swagger file).

In short, we should: remove use of our go-swagger fork, so that we can consume fixes and features from newer versions in upstream.

  • As a short term solution for 1., we could "split" the use; use upstream go-swagger for validating against the spec, and our fork only for generating.
  • Look (again) what features are missing in upstream, or if we can rewrite our use to make it work again with current versions (see Option to skip Validate() methods generation is gone go-swagger/go-swagger#2077)
  • Alternatively, use go-swaggger only for validating, and replace the "generator" code with an alternative implementation; work on that was started in Replace go-swagger with swagger-gen #36714, but there were some issues with that PR (plus it required us to maintain our own generator code, which wasn't ideal either).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions