feat: add /api endpoint returning OpenAPI 3.0.0 specification#196
Open
MridulTailor wants to merge 2 commits intocdnjs:masterfrom
Open
feat: add /api endpoint returning OpenAPI 3.0.0 specification#196MridulTailor wants to merge 2 commits intocdnjs:masterfrom
MridulTailor wants to merge 2 commits intocdnjs:masterfrom
Conversation
MattIPv4
requested changes
Apr 19, 2026
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.
Type of Change
/apiendpoint insrc/routes/api.tswhich returns an OpenAPI 3.0.0 specification dynamically generated from the existing Zod schemas usingOpenAPIRegistry. Integrated intosrc/index.ts.src/utils/openapi.tsto globally initializeextendZodWithOpenApi(z).src/routes/api.spec.tswith 7 tests covering CORS headers, cache headers, status codes, trailing slash resolution, and structural validation of the returned OpenAPI JSON spec.What issue does this relate to?
Closes #189
What should this PR do?
/apiendpoint that returns an OpenAPI 3.0.0 JSON specification for the cdnjs API.@asteasolutions/zod-to-openapias a dependency to dynamically generate the OpenAPI definitions directly from existing Zod schemas (library.schema.ts,libraries.schema.ts, etc.), ensuring response shapes are never manually duplicated and remain easily maintainable.autoupdateproperty) and intersections (required: ['name']) are automatically parsed and translated to OpenAPIoneOf/allOfattributes by the library./apiitself and a servers block pointing tohttps://api.cdnjs.com.libraries.tsandstats.ts) rather than a long-lived immutable cache, keeping the spec updatable as the API evolves.What are the acceptance criteria?
/apiendpoint returns a valid OpenAPI JSON object with descriptions matching the original cdnjs API documentation.npm run types,npm run lint).@cloudflare/vitest-pool-workersthat affects the entire test suite — unrelated to this PR. See Cloudflare Workers known issues.