Cluster 9 · Schema Migration · nullable: true → type array

Migrating OpenAPI 3.0 nullable: true to 3.1 JSON Schema Type Arrays Without Breaking Clients

Exact migration rules for upgrading OpenAPI 3.0.x nullable: true, exclusiveMinimum booleans, and oneOf enums to OpenAPI 3.1.0 JSON Schema 2020-12 without breaking TypeScript, Go, Python, or MCP validators.

Zero Telemetry · Strict CSP (connect-src 'none')

1. Paste OpenAPI Spec (Quick-Lint) & Controls

OAS 2.0 / 3.0 / 3.1 · OWASP API Top 10
Parsed YAML OpenAPI 3.0.3 · 2 ops · 2 {id} routes · 1 nullable: true · ~422 tok
OWASP API Top 10 & MCP Readiness Checklist (100 Points)
Low API Exploit & Token Risk
90 / 100 (A)
HARDENED — OWASP & MCP READY

Passing: 7 · Fixes Needed: 1 · Target: OpenAPI 3.1.0

Est. MCP Schema Tokens
2,070 tok
$9.32/mo at 50 turns/day ($3/1M)
Reclaimable Diet Savings
-345 tok
Saves $1.55/mo via MCPDiet
API2-AUTH (OWASP API2:2023): Explicit components.securitySchemes (Bearer JWT / OAuth2 scopes) + global/op security PASS
Bearer JWT / OAuth2 securitySchemes and security[] requirements are enforced.
API1-BOLA (OWASP API1:2023): Object-ID routes ({id}) enforce explicit 401/403 responses & tenant ownership scopes PASS
Parameterized {id} endpoints verify tenant ownership and document 401/403 status codes.
API3-BOPLA (OWASP API3:2023): additionalProperties: false + readOnly: true on server-owned fields (role, id, plan) PASS
Request schemas lock additionalProperties: false and protect server fields with readOnly: true.
API4-BOUNDS (OWASP API4:2023): maxLength, maxItems, maximum & bounded pagination (limit <= 100 / cursor) on inputs PASS
Strings, arrays, and pagination limits define strict maxLength, maxItems, and maximum bounds.
API8-TLS (OWASP API8:2023): HTTPS-only servers[] URLs (zero http:// prod) + strict CORS allowlist & headers PASS
Production servers[] enforce HTTPS-only URLs and strict origin allowlist CORS.
API4-429 (OWASP API4 / API8): Explicit 401, 403 & 429 Too Many Requests responses with Retry-After / X-RateLimit-* PASS
401, 403, and 429 Too Many Requests responses include Retry-After / X-RateLimit-* headers.
API9-INV (OWASP API9:2023): Versioned base paths + deprecated: true ops declare Sunset header & replacement path PASS
Deprecated endpoints publish Sunset headers and migration paths; zero shadow APIs.
MCP-TOKEN (AI / MCP Readiness): Concise tool descriptions (<= 120 tok/op) & OpenAPI 3.1 type arrays (no nullable: true) HIGH FIX
Verbose descriptions (~43 tok/op) and legacy nullable: true add ~345 wasted MCP pre-prompt tokens.
openapi-owasp-remediation.yaml
openapi: "3.1.0"
info:
  title: "OpenAPI 3.0 -  3.1 Migration API"
  version: "1.0.0"
components:
  schemas:
    WorkspaceMemberCreateRequest:
      type: object
      additionalProperties: false
      required:
        - email
      properties:
        id:
          type: string
          format: uuid
          readOnly: true
        role:
          type: string
          readOnly: true
        email:
          type: string
          format: email
          maxLength: 254
        tags:
          type: array
          maxItems: 20
          items:
            type: string
            maxLength: 32
        nickname:
          type:
            - string
            - "null"
          maxLength: 64
paths:
  /v1/workspaces/{workspaceId}/members:
    get:
      operationId: listWorkspaceMembers
      description: List members for a tenant workspace.
      parameters:
        - name: workspaceId
          in: path
          required: true
          schema:
            type: string
            format: uuid
            maxLength: 36
        - name: limit
          in: query
          schema:
            type: integer
            minimum: 1
            maximum: 100
            default: 25
      responses:
        "200":
          description: Bounded member page
        "401":
          $ref: "#/components/responses/Unauthorized401"
        "403":
          $ref: "#/components/responses/Forbidden403"
        "429":
          $ref: "#/components/responses/TooManyRequests429"
Zero-Upload SpecDiff $49 Remediation PR

Audit Full OpenAPI Specs or Ship a Hardened PR Today

Run a 100% browser-side breaking-change diff, OWASP API Top 10 scan & SARIF 2.1.0 export on SpecDiff (https://spec.runglab.dev), order a $49 Done-For-You OpenAPI & MCP Remediation PR on Creem, or automate via POST /v1/openapi/audit (API Hub), remote MCP tool audit_openapi_spec, and Apify Cloud PPE.

OpenAPI Controls, Bounds & Verification Reference

Rule / Control Hardened Pattern Security & Token Rationale
nullable: true type: ["string", "null"] OpenAPI 3.1 drops `nullable`; use JSON Schema 2020-12 type arrays (plus null in enum)
exclusiveMinimum: true exclusiveMinimum: 0 (numeric) In 3.1, exclusiveMinimum/Maximum take numbers instead of booleans
File Upload Binary contentMediaType / contentEncoding Replaces `type: string, format: binary` inside JSON Schema 2020-12
Tuple Arrays prefixItems + items: false Replaces legacy array-valued `items: [...]` tuple definitions

Side-by-Side: OpenAPI 3.0.3 vs OpenAPI 3.1.0 Nullable & Numeric Bounds

openapi-30-to-31-diff.yaml
# BEFORE (OpenAPI 3.0.3 — fails pure JSON Schema 2020-12 & MCP strict checks)
#   deletedAt:
#     type: string
#     format: date-time
#     nullable: true
#   status:
#     type: string
#     enum: [active, paused]
#     nullable: true
#   amount:
#     type: number
#     minimum: 0
#     exclusiveMinimum: true

# AFTER (OpenAPI 3.1.0 — JSON Schema Draft 2020-12 native)
properties:
  deletedAt:
    type:
      - string
      - "null"
    format: date-time
    maxLength: 40
  status:
    type:
      - string
      - "null"
    enum:
      - active
      - paused
      - null
  amount:
    type: number
    exclusiveMinimum: 0

Detect All 3.0 Keywords Before Upgrading to 3.1

find-30-keywords.sh
# Scan spec for OpenAPI 3.0 keywords removed/changed in 3.1:
grep -nE "nullable:|exclusiveMinimum:s*(true|false)|exclusiveMaximum:s*(true|false)|format:s*(binary|byte)" openapi.yaml

# Diff 3.0 vs 3.1 output schemas for breaking SDK changes:
# https://spec.runglab.dev

Key Engineering Takeaways

  • OpenAPI 3.1.0 aligns 100% with JSON Schema Draft 2020-12 — meaning `nullable: true` is invalid/ignored and must become `type: ["string", "null"]` (and `null` must be included in `enum` if an enum allows null!).
  • Forgetting to include `null` inside `enum: [...]` when switching to `type: ["string", "null"]` causes JSON Schema validators and MCP tool clients to reject `null` values at runtime.
  • Numeric `exclusiveMinimum: true` in 3.0 becomes numeric `exclusiveMinimum: 0` in 3.1 — a common silent failure during automated version bumps.

Common Contract Pitfalls to Avoid

  • Changing only `openapi: "3.0.3"` -> `openapi: "3.1.0"` without rewriting `nullable: true` and `exclusiveMinimum: true`.
  • Writing `null` unquoted in YAML (`- null` vs `- "null"`) inconsistently across YAML parsers (YAML 1.2 treats bare `null` as null literal rather than the string "null" needed inside `type:`).
  • Neglecting to test generated TypeScript (`openapi-typescript`), Python Pydantic, and MCP clients after converting nullable fields.

More OpenAPI OWASP & MCP Optimization Guides

← Back to OpenAPI OWASP & MCP Scorer Hub · 2026 N=26 OpenAPI & MCP Benchmark → · MCP Context Token Cost Calculator → · CORS Preflight & Webhook HMAC Debugger → · SpecDiff Live Diff & SARIF → · $49 Remediation PR →

Frequently Asked Questions

Should `null` inside OpenAPI 3.1 `type:` arrays be quoted as `"null"` in YAML?

Yes! In JSON Schema `type` expects string type names (`"string"`, `"null"`). In YAML, unquoted `null` parses as YAML null rather than the string `"null"` — always write `type: [string, "null"]`.

What happens if I have an `enum` with `type: ["string", "null"]`?

Under JSON Schema 2020-12, `enum` validates exact values regardless of `type` — so if `null` is permitted, include `null` (unquoted YAML null) inside the `enum` list too.

Can SpecDiff compare my 3.0 spec against the migrated 3.1 spec?

Yes — drop both files into https://spec.runglab.dev (100% local in browser) to verify zero accidental contract regressions.