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

Support for multi-file OpenAPI definitions #4542

Closed
Sidonivs opened this issue Apr 23, 2024 · 4 comments
Closed

Support for multi-file OpenAPI definitions #4542

Sidonivs opened this issue Apr 23, 2024 · 4 comments
Labels
duplicate This issue or pull request already exists type:bug A broken experience

Comments

@Sidonivs
Copy link

Sidonivs commented Apr 23, 2024

Possibly a duplicate of issue #4031.

I know issue #4031 is closed, but the problem is still there, I have an OpenAPI file (which has "openapi": "3.0.3") with multiple references to other files (that do not have "openapi": "3.0.3" written in them). Kiota still gives me this output:

crit: Kiota.Builder.KiotaBuilder[0]
      error generating the client: OpenAPI specification version '' is not supported.

Do I need to add "openapi": "3.0.3" to every single referenced file? Why?

@baywet
Copy link
Member

baywet commented Apr 23, 2024

Hi @Sidonivs
Thanks for using kiota and for reaching out.
Do you mean that your OAS description uses external references?

@Sidonivs
Copy link
Author

Sidonivs commented Apr 24, 2024

Hi @Sidonivs Thanks for using kiota and for reaching out. Do you mean that your OAS description uses external references?

Yes. My main OAS file that I am supplying to Kiota looks something like this (the original has many more paths):

{
  "openapi": "3.0.3",
  "info": {
    "description": "text",
    "version": "2.0",
    "title": "title"
  },
  "servers": [
     {
        "url": "https://someurl.com/rest/v%7Bversion:apiVersion%7D"
     }
  ],
  "tags": [
     {
        "name": "dpp",
        "description": "text"
     }
  ],
  "paths": {
     "/dpp": {
        "put": {
           "tags": [
              "dpp"
           ],
           "summary": "putDPP",
           "operationId": "putDPP",
           "parameters": [
              {
                 "in": "query",
                 "name": "source",
                 "description": "text",
                 "required": true,
                  "schema": {
                     "$ref": "../model_v2/OtherSource.json"
                  }
               }
            ],
            "responses": {
               "200": {
                  "description": "OK"
               }
            }
         }
      }
   }
}

And then OtherSource.json is this:

{
  "$schema": "http://json-schema.org/draft-06/schema#",
  "type": "string",
  "enum": [
     "VALUE1",
     "VALUE2",
     "VALUE3",
     "VALUE4",
     "VALUE5",
     "VALUE6"
  ]
}

I also tried generating only this simple example (these 2 exact files) and I get the same error OpenAPI specification version '' is not supported. Another thing I tried is removing "$schema": "http://json-schema.org/draft-06/schema#" from the second file, but still getting the same error.

This is the command I use to run Kiota (version 1.13.0):

kiota generate -d openapi.json -l CSharp -o DataImport.RestClient/Generated -c DppClient -n My.Namespace.DataImport.RestClient.Generated --co --cc

@Sidonivs
Copy link
Author

The OpenAPI Generator for csharp (which I don't like as much as Kiota) doesn't have an issue with generating a client for the above example.

@baywet
Copy link
Member

baywet commented Apr 24, 2024

Unfortunately the parsing library we use under the covers is not really good at resolving the external references for the time being.
This is being worked on as it's a critical part of supporting OpenAPI 3.1 properly, and kiota will adopt this update when it's released.
We're tracking that through #3914 and I'm going to close this issue as a duplicate.

Your best workaround for the time being is to use hidi to inline all external references, and then feed the result to kiota.
https://github.com/microsoft/OpenAPI.NET/tree/vnext/src/Microsoft.OpenApi.Hidi

@baywet baywet closed this as not planned Won't fix, can't repro, duplicate, stale Apr 24, 2024
@baywet baywet added type:bug A broken experience duplicate This issue or pull request already exists and removed question Needs: Attention 👋 labels Apr 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists type:bug A broken experience
Projects
Archived in project
Development

No branches or pull requests

2 participants