feat: add /api endpoint returning OpenAPI 3.0.0 specification#196
Open
MridulTailor wants to merge 1 commit intocdnjs:masterfrom
Open
feat: add /api endpoint returning OpenAPI 3.0.0 specification#196MridulTailor wants to merge 1 commit intocdnjs:masterfrom
MridulTailor wants to merge 1 commit 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.tsreturning an OpenAPI 3.0.0 specification as a plain TypeScript object. Integrated intosrc/index.ts.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.library.schema.ts,libraries.schema.ts) to OpenAPI JSON Schema format, avoiding any new runtime dependencies.autoupdateproperty using OpenAPIoneOfto reflect thez.uniondefinition, enforcingtype/targetandsource/targetvariants with their respectiverequiredfields.required: ['name']on library result items, honouring the.and({ name, latest })Zod constraint./apiitself and aserversblock 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 3.0.0 JSON object with descriptions matching the original cdnjs API documentation.npm run types,npm run lint).semverCommonJS module resolution issue in@cloudflare/vitest-pool-workersthat affects the entire test suite — unrelated to this PR. See [Cloudflare Workers known issues](https://developers.cloudflare.com/workers/testing/vitest-integration/known-issues/#module-resolution).