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

Error when generating an API plugin #4715

Closed
maisarissi opened this issue May 23, 2024 · 3 comments · Fixed by #4722
Closed

Error when generating an API plugin #4715

maisarissi opened this issue May 23, 2024 · 3 comments · Fixed by #4722
Assignees
Labels
type:bug A broken experience
Milestone

Comments

@maisarissi
Copy link
Contributor

What are you generating using Kiota, clients or plugins?

Kiota plugin

In what context or format are you using Kiota?

Windows executable

Client library/SDK language

None

Describe the bug

I'm able to search and find the GitHub OpenAPI description and select the endpoints I care about, which are:

  • /repos/{owner}/{repo}#GET
  • /repos/{owner}/{repo}#PATCH
  • /repos/{owner}/{repo}#DELETE

When trying to generate an "API Plugin" for the above endpoints, I got the following error:
image

In the output folder, both generated files (plugin and sliced openapi) are wrong.
Plugin file has no functions nor runtimes objects.

{
  "schema_version": "v2",
  "name_for_human": "GitHub v3 REST API",
  "description_for_human": "GitHub\u0026apos;s v3 REST API.",
  "description_for_model": "GitHub\u0026apos;s v3 REST API.",
  "logo_url": "https://api.apis.guru/v2/cache/logo/https_twitter.com_github_profile_image.jpeg",
  "namespace": "githubrepo",
  "capabilities": {
    "localization": {}
  }
}

The sliced OpenAPI description has no "paths".

openapi: 3.0.1
info:
  title: GitHub v3 REST API
  description: GitHub's v3 REST API.
  termsOfService: https://docs.github.com/articles/github-terms-of-service
  contact:
    name: Support
    url: https://support.github.com/contact?tags=dotcom-rest-api
  license:
    name: MIT
    url: https://spdx.org/licenses/MIT
  version: '1.1.4'
  x-apisguru-categories:
    - collaboration
    - developer_tools
  x-github-plan: api.github.com
  x-logo:
    url: https://api.apis.guru/v2/cache/logo/https_twitter.com_github_profile_image.jpeg
  x-origin:
    - format: openapi
      url: https://raw.githubusercontent.com/github/rest-api-description/main/descriptions/api.github.com/api.github.com.json
      version: '3.0'
  x-providerName: github.com
  x-serviceName: api.github.com
servers:
  - url: https://api.github.com
paths: { }
components: ...

Using the same extension version I'm able to correctly generate an API Plugin for other GitHub endpoints, like /search node.
Also, after getting the above error, I'm not able to load a new OpenAPI description. For that, I need to close and reopen VS Code.

Expected behavior

I should be able to generate an API plugin with functions and runtime for the selected endpoints as well as have a sliced OpenAPI description with only the selected endpoints in the paths

How to reproduce

Just try to generate a plugin for all the following endpoints:

  • /repos/{owner}/{repo}#GET
  • /repos/{owner}/{repo}#PATCH
  • /repos/{owner}/{repo}#DELETE

Open API description file

No response

Kiota Version

plugin feature

Latest Kiota version known to work for scenario above?(Not required)

No response

Known Workarounds

No response

Configuration

No response

Debug output

Click to expand log ```
</details>


### Other information

_No response_
@maisarissi maisarissi added type:bug A broken experience status:waiting-for-triage An issue that is yet to be reviewed or assigned labels May 23, 2024
@github-project-automation github-project-automation bot moved this to Needs Triage 🔍 in Kiota May 23, 2024
@maisarissi maisarissi moved this from Needs Triage 🔍 to Todo 📃 in Kiota May 23, 2024
@maisarissi maisarissi removed the status:waiting-for-triage An issue that is yet to be reviewed or assigned label May 23, 2024
@andrueastman andrueastman self-assigned this May 24, 2024
@andrueastman
Copy link
Member

andrueastman commented May 24, 2024

Looks like the extension shows/sends /repos/{org-id}/{repo-id}#GET as the include pattern while the openapi description has the path as /repos/{owner}/{repo}#GET(this is due to the path deduplication logic by kiota).

Authored #4722 to resolve the issue with the indexer cleanup logic that doesn't add a wildcard for the last indexer.

@andrueastman andrueastman moved this from Todo 📃 to In Progress 🚧 in Kiota May 24, 2024
@andrueastman andrueastman added this to the Kiota v1.15 milestone May 24, 2024
@github-project-automation github-project-automation bot moved this from In Progress 🚧 to Done ✔️ in Kiota May 24, 2024
@maisarissi
Copy link
Contributor Author

maisarissi commented May 24, 2024

@andrueastman will this fix the extension showing the wrong path?
image

FYI @ElinorW

@andrueastman
Copy link
Member

The extension will show the deduplicated paths /repos/{org-id}/{repo-id} this is because the document has some paths as
/repos/{owner}/{repo} and others as /repos/{template_owner}/{template_repo}. So Kiota will deduplicate them to avoid having multiple branches as that is ambiguous from an openaApi standpoint.

This is similar to the scenario to the test at

public void SinglePathParametersAreDeduplicatedAndOrderIsRespected()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:bug A broken experience
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants