microsoft / kiota

OpenAPI based HTTP Client code generator
https://aka.ms/kiota/docs
MIT License
3.01k stars 210 forks source link

For show/download can we fallback to a registry's cached copy if the origin URL fails? #1897

Closed darrelmiller closed 2 years ago

darrelmiller commented 2 years ago

This fails

kiota show -k apisguru::polygon.io

but the copy maintained by apisguru is valid

https://raw.githubusercontent.com/APIs-guru/openapi-directory/main/APIs/polygon.io/1.0.0/swagger.yaml
baywet commented 2 years ago

Is the URL of the copy somewhere in the index file?

darrelmiller commented 2 years ago

Looking at this index https://api.apis.guru/v2/list.json the polygon entry

"polygon.io": {
    "added": "2017-11-26T16:58:20.000Z",
    "preferred": "1.0.0",
    "versions": {
      "1.0.0": {
        "added": "2017-11-26T16:58:20.000Z",
        "info": {
          "contact": {
            "x-twitter": "polygon_io"
          },
          "description": "The future of fintech.",
          "title": "Polygon",
          "version": "1.0.0",
          "x-apisguru-categories": [
            "financial"
          ],
          "x-logo": {
            "url": "https://api.apis.guru/v2/cache/logo/https_twitter.com_polygon_io_profile_image.jpeg"
          },
          "x-origin": [
            {
              "format": "swagger",
              "url": "https://polygon.io/docs/swagger.json",
              "version": "2.0"
            }
          ],
          "x-providerName": "polygon.io"
        },
        "updated": "2017-11-27T13:03:31.000Z",
        "swaggerUrl": "https://api.apis.guru/v2/specs/polygon.io/1.0.0/swagger.json",
        "swaggerYamlUrl": "https://api.apis.guru/v2/specs/polygon.io/1.0.0/swagger.yaml",
        "openapiVer": "2.0"
      }
    }
  },

When doing kiota show -k apisguru::polygon.io it is trying to download from the x-origin instead of downloading from the swaggerUrl. The SwaggerUrl contains the apis.guru version that has corrections made. We should consider always reading from the apis-guru version.