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(openapi): support configuration via openapi #2299

Merged
merged 11 commits into from Apr 3, 2024

Conversation

hanspagel
Copy link
Contributor

@hanspagel hanspagel commented Mar 22, 2024

WIP need to update the dependency to fix the build

πŸ”— Linked issue

–

❓ Type of change

  • πŸ“– Documentation (updates to the documentation, readme, or JSdoc annotations)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

  1. This PR makes the OpenAPI endpoint configurable (title, description, version). It’s still possible to just pass experimental.openAPI: true, but you can also pass an object. This should make it a non-breaking addition.

  2. With this PR you can also pass a configuration for Scalar (eg. to use other themes). It’s optional, but enables users to use a ton of powerful features. More on this here: https://github.com/scalar/scalar?tab=readme-ov-file#configuration

  3. This PR removes the Scalar proxy. It’s really helpful to avoid CORS issues when using the API client, but you can’t use an external proxy to send request to localhost, so it’s not really helpful for local development.

Note: This PR also adds @scalar/api-reference as a dev dependency, just to import the configuration type for convenience. We could also remove it and just allow AnyObject (not so helpful, though), copy the type to the package (which might be outdated quickly) or we move our types to a separate package. It seems to break the build, we definitely need to change this. What route should we take? πŸ€”

I’d love to add some tests, too, but haven’t looked into that yet. That’s why I submitted it as a draft for now.

Any kind of feedback is really appreciated! We’re eager to make the OpenAPI stuff really great for everyone.

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@hanspagel hanspagel changed the title feat: make OpenAPI and Scalar endpoint configurable feat(openapi): make OpenAPI and Scalar endpoint configurable Mar 22, 2024
src/types/nitro.ts Outdated Show resolved Hide resolved
src/types/nitro.ts Outdated Show resolved Hide resolved
@pi0 pi0 marked this pull request as ready for review April 3, 2024 12:58
@pi0 pi0 changed the title feat(openapi): make OpenAPI and Scalar endpoint configurable feat(openapi): support configuration via openapi Apr 3, 2024
@pi0 pi0 merged commit b2f22e9 into unjs:main Apr 3, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants