Skip to content

fix(license): support SPDX identifier field in OAS v3.1.0 License Object#1365

Merged
sserrata merged 5 commits intomainfrom
fix/license-identifier-oas-3-1
Mar 30, 2026
Merged

fix(license): support SPDX identifier field in OAS v3.1.0 License Object#1365
sserrata merged 5 commits intomainfrom
fix/license-identifier-oas-3-1

Conversation

@sserrata
Copy link
Copy Markdown
Member

Summary

  • OAS v3.1.0 added an identifier field to the License Object as an SPDX expression, mutually exclusive with url
  • createLicense only rendered content when url was present; specs using identifier got an empty License section
  • Adds a guard(identifier, ...) block that links to https://spdx.org/licenses/<identifier>.html

Test plan

  • Verify a spec with license.identifier: Apache-2.0 (and no url) renders a clickable "Apache 2.0" link pointing to https://spdx.org/licenses/Apache-2.0.html
  • Verify a spec with license.url still renders correctly (no regression)
  • Verify a spec with only license.name (no url or identifier) renders the section header without a link (existing behavior)

Closes #1319

🤖 Generated with Claude Code

sserrata and others added 5 commits March 30, 2026 12:57
Move qualifier-message rendering fully to the theme layer so that
Docusaurus i18n can translate the human-readable constraint strings:
- "characters" (minLength / maxLength)
- "non-empty" (minLength === 1)
- "Value must match regular expression" (pattern)

Architecture:
- `getQualifierMessage` is removed from the plugin and kept only in
  the theme (`docusaurus-theme-openapi-docs/src/markdown/schema.ts`),
  where `translate()` is available at render time.
- `SchemaItem` now computes `qualifierMessage` from its `schema` prop
  when the caller doesn't pass one explicitly, so all callers are
  simplified — no more `qualifierMessage={getQualifierMessage(schema)}`
  at every call site.
- Plugin `createSchema.ts` and `Schema/index.tsx` drop all
  `qualifierMessage` prop passes; the theme component handles it.
- `utils.ts` `create()` skips props with `undefined` values, cleaning
  up generated MDX.
- Dead code removed: `humanizeConstraints`, `humanizeNumberRange`, and
  related helpers were exported but unused.

Translation IDs added:
  theme.openapi.schemaItem.characters
  theme.openapi.schemaItem.nonEmpty
  theme.openapi.schemaItem.expression

Demo directory intentionally untouched (no locale config added).

Closes #1249. Credit: @dsuket

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds rendering support for the `identifier` field introduced in OAS v3.1.0,
which is mutually exclusive with `url`. When present, links to the canonical
SPDX license page at https://spdx.org/licenses/<identifier>.html.

Closes #1319
Adds licenseIdentifier.yaml to demo/examples/tests to verify that a spec
using license.identifier renders a clickable SPDX license link correctly.

Related to #1319
Required for createLicense.ts to compile after adding SPDX identifier support.

Closes #1319
@github-actions
Copy link
Copy Markdown

Size Change: +5.17 kB (+0.23%)

Total Size: 2.21 MB

Filename Size Change
demo/.docusaurus/globalData.json 66.1 kB +714 B (+1.09%)
demo/.docusaurus/registry.js 95.7 kB +1.02 kB (+1.08%)
demo/.docusaurus/routes.js 90.6 kB +978 B (+1.09%)
demo/.docusaurus/routesChunkNames.json 37.5 kB +411 B (+1.11%)
demo/build/assets/js/main.********.js 658 kB +1.85 kB (+0.28%)
demo/build/assets/js/runtime~main.********.js 22.5 kB +196 B (+0.88%)
ℹ️ View Unchanged
Filename Size
demo/.docusaurus/codeTranslations.json 2 B
demo/.docusaurus/docusaurus.config.mjs 14.7 kB
demo/.docusaurus/i18n.json 372 B
demo/.docusaurus/site-metadata.json 1.51 kB
demo/build/assets/css/styles.********.css 164 kB
demo/build/index.html 97.6 kB
demo/build/petstore/add-pet/index.html 29.3 kB
demo/build/petstore/create-user/index.html 24 kB
demo/build/petstore/create-users-with-array-input/index.html 24.1 kB
demo/build/petstore/create-users-with-list-input/index.html 24.1 kB
demo/build/petstore/delete-order/index.html 23.8 kB
demo/build/petstore/delete-pet/index.html 24.1 kB
demo/build/petstore/delete-user/index.html 24.3 kB
demo/build/petstore/find-pets-by-status/index.html 24.8 kB
demo/build/petstore/find-pets-by-tags/index.html 25.4 kB
demo/build/petstore/get-inventory/index.html 23.1 kB
demo/build/petstore/get-order-by-id/index.html 24.1 kB
demo/build/petstore/get-pet-by-id/index.html 24.9 kB
demo/build/petstore/get-user-by-name/index.html 24.4 kB
demo/build/petstore/login-user/index.html 24.9 kB
demo/build/petstore/logout-user/index.html 23.7 kB
demo/build/petstore/new-pet/index.html 24.3 kB
demo/build/petstore/pet/index.html 22.5 kB
demo/build/petstore/place-order/index.html 23.3 kB
demo/build/petstore/schemas/apiresponse/index.html 24.6 kB
demo/build/petstore/schemas/cat/index.html 38.7 kB
demo/build/petstore/schemas/category/index.html 25.7 kB
demo/build/petstore/schemas/dog/index.html 39 kB
demo/build/petstore/schemas/honeybee/index.html 39.1 kB
demo/build/petstore/schemas/id/index.html 22.7 kB
demo/build/petstore/schemas/order/index.html 26.8 kB
demo/build/petstore/schemas/pet/index.html 38.5 kB
demo/build/petstore/schemas/tag/index.html 24.1 kB
demo/build/petstore/schemas/user/index.html 40.6 kB
demo/build/petstore/store/index.html 21.5 kB
demo/build/petstore/subscribe-to-the-store-events/index.html 30.2 kB
demo/build/petstore/swagger-petstore-yaml/index.html 30.2 kB
demo/build/petstore/update-pet-with-form/index.html 24.3 kB
demo/build/petstore/update-pet/index.html 24.7 kB
demo/build/petstore/update-user/index.html 24.3 kB
demo/build/petstore/upload-file/index.html 24.1 kB
demo/build/petstore/user/index.html 22.2 kB

compressed-size-action

@github-actions
Copy link
Copy Markdown

Visit the preview URL for this PR (updated for commit ce454f5):

https://docusaurus-openapi-36b86--pr1365-3o9e7ijz.web.app

(expires Wed, 29 Apr 2026 17:29:05 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: bf293780ee827f578864d92193b8c2866acd459f

@sserrata sserrata merged commit 216d6bd into main Mar 30, 2026
11 checks passed
@sserrata sserrata deleted the fix/license-identifier-oas-3-1 branch March 30, 2026 18:05
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.

License identifier results in empty License section (OAS v3.1.0+)

1 participant