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

feat(vscode): add openapi3 preview #6015

Open
wants to merge 53 commits into
base: main
Choose a base branch
from

Conversation

archerzz
Copy link
Member

@archerzz archerzz commented Feb 14, 2025

  • add command to preview the main.tsp of the selected tsp file
    • each main tsp can have its own preview panel
    • preview panel will auto-refresh when a tsp file is changed
  • if multiple swagger definition is generated, command will prompt users to select one
    • the selection will be kept until the preview panel is closed
  • swagger definition is generated to a temp folder
    • temp folders will be cleared on deactivation
  • a minimal version of tsp 0.65.0 is required to simplify implementation
  • due to vsce package not supporting pnpm, I have to copy swagger-ui-dist lib files into our source folder. So, add those files into ignore list of lint and format.

resolve #4858

@archerzz
Copy link
Member Author

I have to copy swagger-ui-dist libs instead of importing them as dependencies, because pnpm is actually not supported in vsce package.

@azure-sdk
Copy link
Collaborator

azure-sdk commented Feb 14, 2025

All changed packages have been documented.

  • typespec-vscode
Show changes

typespec-vscode - feature ✏️

add openapi3 preview

@azure-sdk
Copy link
Collaborator

azure-sdk commented Feb 14, 2025

You can try these changes here

🛝 Playground 🌐 Website 📚 Next docs 🛝 VSCode Extension

@RodgeFu RodgeFu added the ide Issues for VS, VSCode, Monaco, etc. label Feb 14, 2025
@archerzz
Copy link
Member Author

https://github.com/arjun-g/vs-swagger-viewer is not suitable as a dependent extension for previewing swagger, because it only exposes a load method, which doesn't fulfill our requirement:

  • We cannot get the panel instance, which means:
    • we don't know when the panel is closed
    • we cannot manually switch panel from background to front ground
  • It maintains an HTTP server internally, which means more runtime footprint

weidongxu-microsoft and others added 19 commits February 21, 2025 10:46
…#6054)

I forgot to trace stderr. For error in postprocess/customization, the
error log is on stderr.
…oft#5937)

This should work as long as the template has a string representation.

fix [microsoft#5391](microsoft#5391)
Add test to confirm that this
microsoft#5197 is not an issue
This is replaced by the README.md file.
Fix microsoft#5899

- remove typespec extension out of preview model
Fixes microsoft#6090

Include emitter tests in the build so we can catch compilation errors.
They are excluded from the tgz tested using `npm pack`.
@archerzz
Copy link
Member Author

List of changes since last review:

  • update ordering of commands and menu items according to comments
  • refactor parseOpenApi3File to make it generic
    • add a new parseOpenApi3File in the openapi3-preview.ts which handles UI specific logic
  • add selected file in the error logs if it's available

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ide Issues for VS, VSCode, Monaco, etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Preview typespec with swagger-ui in vscode