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

When editing the workspace.json and clicking on re-generate, the API client/ API plugin should be regenerated successfully #4870

Closed
maisarissi opened this issue Jun 20, 2024 · 6 comments · Fixed by #4917
Assignees
Labels
enhancement New feature or request type:enhancement Enhancement request targeting an existing experience vscode-extension Work related to the vscode-extension
Milestone

Comments

@maisarissi
Copy link
Contributor

maisarissi commented Jun 20, 2024

Given the following workspace.json

{
  "version": "1.0.0",
  "clients": {},
  "plugins": {
    "GitHubIssues": {
      "types": [
        "APIPlugin"
      ],
      "descriptionLocation": "https://raw.githubusercontent.com/APIs-guru/openapi-directory/gh-pages/v2/specs/github.com/1.1.4/openapi.json",
      "includePatterns": [
        "/search/issues#GET"
      ],
      "excludePatterns": [],
      "outputPath": "./appPackage"
    },
    "GitHubReposOwner": {
      "types": [
        "APIPlugin"
      ],
      "descriptionLocation": "https://raw.githubusercontent.com/APIs-guru/openapi-directory/gh-pages/v2/specs/github.com/1.1.4/openapi.json",
      "includePatterns": [
        "/repos/{org-id}/{repo-id}#DELETE",
        "/repos/{org-id}/{repo-id}#GET",
        "/repos/{org-id}/{repo-id}#PATCH"
      ],
      "excludePatterns": [],
      "outputPath": "./appPackage"
    }
  }
}

If I make a manual change to add another type to my GitHubReposOwner Plugin:

"GitHubReposOwner": {
      "types": [
        "APIPlugin",
        "APIManifest" //added a new type
      ],
      "descriptionLocation": "https://raw.githubusercontent.com/APIs-guru/openapi-directory/gh-pages/v2/specs/github.com/1.1.4/openapi.json",
      "includePatterns": [
        "/repos/{org-id}/{repo-id}#DELETE",
        "/repos/{org-id}/{repo-id}#GET",
        "/repos/{org-id}/{repo-id}#PATCH"
      ],
      "excludePatterns": [],
      "outputPath": "./appPackage"
    }

When I hit "Re-generate" in the codelense, I get the message that the plugin was re-generated successfully, but the API Manifest file is not generated and the workspace.json file is reloaded and the apimanifest type is removed from my plugin type.

I also cannot change the type to either OpenAI nor API Manifest. If I try to change the type, or even create a new entry manually with OpenAI or API Manifest types and re-generate, Kiota changes it to APIPlugin type and generates the plugin and sliced OpenAPI description.

Expected:
All changes made manually and saved to the workspace.json file, should be used to re-generated the plugin and generate the right output files.

@maisarissi maisarissi added type:bug A broken experience vscode-extension Work related to the vscode-extension status:waiting-for-triage An issue that is yet to be reviewed or assigned labels Jun 20, 2024
@maisarissi maisarissi added this to the Kiota v1.16 milestone Jun 20, 2024
@baywet
Copy link
Member

baywet commented Jun 20, 2024

@maisarissi this is probably because the file was loaded in memory whenever you "opened" it, and never reloaded from storage after the modification and before the information was sent to the kiota engine.
From what I remember from vscode APIs, we have the ability to subscribe to file changes. When the event is triggered though it can mean a couple of things: the user didn't make any modification in the UI, we can safely reload things. The user has made modifications, in which case we'd need to prompt them before reloading.
And of course, we should ignore events triggered right after a generation.

This should be considered in combination with #4853 and some preliminary work on UI/behaviour would be helpful to make sure everyone involved has the same understanding here.

Lastly, I'm going to re-tag that as an enhancement since we never spec'd it out at the first place.

@baywet baywet modified the milestones: Kiota v1.16, Kiota v1.17 Jun 20, 2024
@baywet baywet added enhancement New feature or request type:enhancement Enhancement request targeting an existing experience and removed type:bug A broken experience status:waiting-for-triage An issue that is yet to be reviewed or assigned labels Jun 20, 2024
@sebastienlevert
Copy link
Contributor

Which "Re-generate" this is? The codelense (the one in the file) or the one in the API Explorer? I don't expect the API explorer one to work, while I expect the one from the file to work.

@maisarissi
Copy link
Contributor Author

@sebastienlevert The codelense as I'm doing manual changes!

@sebastienlevert
Copy link
Contributor

So while I understand this might have a "non-spec" element, I think it's part of the feature to fix it. I see this a a bug more than an enhancement.

@maisarissi
Copy link
Contributor Author

maisarissi commented Jun 20, 2024

+1 to Sebastien's point.

Also, I can add a new entry and hit re-generate, and Kiota will generate the new files for me, the issue though is that Kiota changes all types to be "APIPlugin" and do not accepted more than 1 type in each entry (what it should).

I see as a bug as well.

@baywet
Copy link
Member

baywet commented Jun 20, 2024

If you PMs want to nit pick... I'm going to ask for the spec for the code lens... 😈
But sure, we essentially need to subscribe to file changes. We might want to window them over 1-2s or so to avoid overloading vscode as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request type:enhancement Enhancement request targeting an existing experience vscode-extension Work related to the vscode-extension
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

4 participants