question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Remove swagger: 2.0 from spec

See original GitHub issue

The current OpenAPI spec has "swagger": "2.0" in it. Since it’s no longer called the swagger spec, this should go away.

I do believe we should continue to declare the version in the specification though, to make tooling more tolerant. Some points about that.

  • One major issue with the Swagger 2.0 tooling was that it was looking for the “2.0” version in the spec itself. That meant, a “2.0.1” spec–even if structurally compatible–would not work. We should advise all tooling vendors as to versioning process and how they should detect versions inside the spec. Reference the concerns in #107. In a couple cases we probably should have bumped the spec version in 2.0 to 2.0.1, etc. Let’s not make that mistake again
  • Declaring a semver approach for the spec makes sense. We don’t need to go too far into the details in this ticket as to what constitutes a major, minor, patch version, but in general, if we put a version in the next spec version (which I advocate), it should be in the x.y.z format.
  • Making it “2.0” as a string vs. number was dumb. The above point solves that.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:15 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
IvanGoncharovcommented, Mar 14, 2016

@fehguy In that case, I suggest to change $schema: https://openapis.org/schemas/v3.0.0.json into $schema: https://openapis.org/version/v3.0.0/schemas/latest.json. In this case latest is alias for the lastest version of schema corresponding to OAI v3.0.0. But if you want to be precise you can set it to: $schema: https://openapis.org/version/v3.0.0/schemas/v1.0.1.json Which will point to v1.0.1 of the schema for OAI v3.0.0.

Aliasing isn’t a problem since Git support symlinks.

1reaction
fehguycommented, Mar 14, 2016

Here is my proposal for addressing this.

Options:

  • We can use the schema namespace instead of a OAI version
  • We can use a oas attribute for the version

Pros:

  • schema URL is more flexible.
  • oas is more tooling friendly. Most tools cannot do much with a new version of the schema

Cons:

  • schema url is very long. Useful for validation, not for interpretation
  • oas as a numeric version has the same issue as swagger: "2.0"

Recommendation:

  • use the oas specifier with semver semantics:
oas: 3.0.0-alpha

which will eventually be released as:

oas: 3.0.0

The multiple . will avoid the string/number issue from swagger: 2.0

  • introduce an optional schema URL which can be used for validation. If absent, the tooling will choose the appropriate OAS schema.

  • Tooling will be responsible for parsing with semver compatibilty:

    Given a version number MAJOR.MINOR.PATCH, increment the:

    • MAJOR version when you make incompatible API changes,
    • MINOR version when you add functionality in a backwards-compatible manner, and
    • PATCH version when you make backwards-compatible bug fixes.
    • Additional labels for pre-release and build metadata are available as extensions to the MAJOR.MINOR.PATCH format

example:

oas: 3.0.0
schema: https://openapis.org/schemas/v3.0.0.json
Read more comments on GitHub >

github_iconTop Results From Across the Web

OpenAPI Specification - Version 2.0 - Swagger
Version 2.0 specification defines a set of files required to describe an API. ... can be overridden at the operation level, but cannot...
Read more >
How to Turn Off Swagger-ui in Production - Baeldung
In this short tutorial, we'll look at how to turn Swagger off in production. 2. Swagger Configuration.
Read more >
api - How to reuse swagger definitions and remove some of ...
I want to lessen my code so I reused the User definition as my schema. The problem here is that I do not...
Read more >
Guide - 7.10.12.2 Migrating to OpenApi 3.0 and Swagger 2.X ...
Annotations for Operations ; @ApiOperation, @Operation, See below for usage ; @APIResponses, removed, See below for usage ; @APIResponse, @ApiResponse, See below ...
Read more >
Migrating from SpringFox - Springdoc-openapi
Remove springfox and swagger 2 dependencies. Add springdoc-openapi-ui dependency instead. ... Replace swagger 2 annotations with swagger 3 ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found