Skip to content

deps: migrate to OpenAPI 3.1+ and use unevaluatedProperties for strict validation #87

@ericfitz

Description

@ericfitz

Summary

Migrate the OpenAPI specification from 3.0.3 to 3.1+ to enable proper use of unevaluatedProperties: false for strict request validation in schemas that use allOf composition.

Background

TMI uses allOf composition in the OpenAPI spec to:

  • Separate request-only and response-only fields (e.g., DfdDiagramInput vs DfdDiagram)
  • Compose schemas from base types (e.g., Node extends Cell)

The Problem

In OpenAPI 3.0 / JSON Schema draft-07, additionalProperties: false at the top level of a schema with allOf causes validation to reject properties that ARE defined in the referenced schemas. This is because additionalProperties applies to the local schema level, not the merged result.

Example: The Node schema had:

{
  "allOf": [
    { "$ref": "#/components/schemas/Cell" },
    {
      "properties": {
        "angle": { "type": "number" },
        ...
      }
    }
  ],
  "additionalProperties": false  // This rejects "angle" even though it's defined above!
}

Current Workaround

We removed additionalProperties: false from schemas that use allOf:

  • Node
  • Edge
  • DfdDiagram
  • DfdDiagramInput
  • Note
  • Asset
  • ExtendedAsset

This allows X6 diagram properties (like angle, zIndex, etc.) to pass validation, but loses strict validation on these schemas.

Solution

OpenAPI 3.1 (based on JSON Schema 2020-12) introduces unevaluatedProperties: false, which is designed to work correctly with schema composition. It considers properties from all composed schemas as "evaluated" and only rejects truly unknown properties.

Blocked By

Tasks

  • Monitor oapi-codegen for OpenAPI 3.1 support
  • When supported, update openapi field in spec from 3.0.3 to 3.1.0
  • Replace additionalProperties: false with unevaluatedProperties: false in affected schemas
  • Update any nullable fields to use type: ["string", "null"] syntax (3.1 change)
  • Validate with updated tooling
  • Regenerate API code
  • Run full test suite

References

Labels

  • enhancement
  • schema
  • blocked

Metadata

Metadata

Assignees

No one assigned

    Labels

    dependenciesPull requests that update a dependency fileenhancementNew feature or request

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions