Skip to main content

required-dollar-id-in-root-schema

Overview

This rule belongs to the openapi-v3-standards-linting ruleset and states that:

The root schema of a JSON Schema document or a root Schema Object defined/referenced directly in a component of an OpenAPI document (e.g. Parameter Object, Header Object or a Media Type Object) should contain the $id property which uniquely identifies the schema and also helps indicate the Base URI for resolving relative references within the schema definition. The value of $id must be a valid absolute URI as per RFC3986. This URI must contain a scheme, but no fragment.

PropertyValue
EnabledYes
Maximum SeverityWarning
Message$id is missing from root schema.
CodeOPENAPI3STANDARDS_L156
TypeLinting
Rule SystemSemantic
Broad CategorySchemas
Products ImpactedAPI Transformer, Code Generation, Developer Experience Portal
Tagsopenapi3 openapi standards semantic linting id $id schema

Suggested Fixes

  • Add property $id in the Schema Object with a value which is a valid URI, contains a scheme but no fragment.
  • Ensure that the $id value is non-empty and non-null.
  • When a Schema Object references an external JSON schema document, the schema resource defined directly in this document at root level is considered the root schema.
  • In an OpenAPI document a schema directly defined or referenced in a Parameter Object, Header Object or Media Type Object is considered a root schema.

For More Information