feat(plugin-swagger): add OpenAPI runtime mode for Fastify#1408
Draft
jpina1-godaddy wants to merge 4 commits into
Draft
feat(plugin-swagger): add OpenAPI runtime mode for Fastify#1408jpina1-godaddy wants to merge 4 commits into
jpina1-godaddy wants to merge 4 commits into
Conversation
Adds a `swagger.openapi` config option to `@gasket/plugin-swagger` that
enables runtime route introspection via `@fastify/swagger` instead of
loading a static definition file. When set, the build step is skipped,
Express warns and exits early, and the Fastify hook registers
`@fastify/swagger` in openapi mode with `timing: { first: true }` so
routes are always discovered regardless of registration order.
Made-with: Cursor
🦋 Changeset detectedLatest commit: 9dedc2c The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
…nfig
Introduces swagger.mode ('static'|'introspect') and swagger.spec to
make the distinction between static file serving and Fastify route
introspection explicit and configurable. Defaults to 'static' for full
backward compatibility with existing apps.
- configure hook defaults mode to 'static'
- build hook skips file generation only in introspect mode
- fastify hook auto-detects spec format from content in both modes
- warns when swagger.spec is set without mode: 'introspect'
- warns when swagger.jsdoc is set with mode: 'introspect'
- warns when mode: 'introspect' is used with Express
Made-with: Cursor
- Replace mode/spec config with a single swagger.introspect object that enables @fastify/swagger route introspection. Format (OpenAPI 3.x vs Swagger 2.0) is auto-detected from the object's keys. - Add swagger.introspect.routes with include/exclude prefix arrays to filter which Fastify routes appear in the generated spec. The routes property is stripped before being passed to @fastify/swagger. - Improve static Fastify path: auto-detect openapi vs swagger key from the loaded spec file instead of always using swagger. - Guard against invalid introspect values with a clear error message. - Warn when include/exclude prefix entries are missing a leading slash. - Log a warning when swagger.introspect is used with Express. - Add 13 new tests covering introspect.routes filtering, routes stripping, transform function correctness, and input validation. - Fix trailing comma lint error and invalid JSDoc tag warning. Made-with: Cursor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
swagger.openapiconfig option to@gasket/plugin-swaggerthat enables runtime route introspection via@fastify/swagger, removing the need for a static definition file.fastifyhook now usestiming: { first: true }so@fastify/swaggeris always registered before any route-defining plugins, ensuring all routes are automatically discovered without any extra configuration by consumers.swagger.openapiis set: thebuildstep is skipped, and Express warns and exits early (OpenAPI mode is Fastify-only).uiConfig→uiOptions,apiDocs→apiDocsRoute.Test plan
swagger.openapimode shows all routes in Swagger UI without anyaftertiming declarations in route pluginsbuildhook is skipped whenswagger.openapiis setswagger.openapiis setnpx vitest runinpackages/gasket-plugin-swaggerMade with Cursor