Schema.org · API Governance Rules

Schema.org API Rules

Spectral linting rules defining API design standards and conventions for Schema.org.

10 Rules error 5 warn 5
View Rules File View on GitHub

Rule Categories

schema

Rules

error
schema-org-context-required
JSON-LD documents must include @context pointing to schema.org
$
error
schema-org-type-required
JSON-LD documents must include @type declaring the Schema.org type
$
warn
schema-org-name-recommended
Most Schema.org types should have a name property
$[?(@type)]
error
schema-org-url-format
URL properties must be valid URIs
$.url
warn
schema-org-same-as-format
sameAs references should be valid URIs
$.sameAs
warn
schema-org-aggregate-rating-values
AggregateRating must include ratingValue
$[?(@type == 'AggregateRating')]
error
schema-org-offer-price-currency
Offers must include both price and priceCurrency
$[?(@type == 'Offer')]
warn
schema-org-webapi-documentation
WebAPI types should include documentation URL
$[?(@type == 'WebAPI')]
warn
schema-org-organization-url
Organization entities should include a URL
$[?(@type == 'Organization')]
error
schema-org-person-name
Person entities must include a name
$[?(@type == 'Person')]

Spectral Ruleset

schema-org-rules.yml Raw ↑
rules:
  schema-org-context-required:
    description: JSON-LD documents must include @context pointing to schema.org
    message: "JSON-LD structured data must include @context with schema.org or https://schema.org"
    severity: error
    given: "$"
    then:
      field: "@context"
      function: truthy

  schema-org-type-required:
    description: JSON-LD documents must include @type declaring the Schema.org type
    message: "JSON-LD structured data must include @type"
    severity: error
    given: "$"
    then:
      field: "@type"
      function: truthy

  schema-org-name-recommended:
    description: Most Schema.org types should have a name property
    message: "Schema.org entities should have a name property for human-readable identification"
    severity: warn
    given: "$[?(@type)]"
    then:
      field: name
      function: truthy

  schema-org-url-format:
    description: URL properties must be valid URIs
    message: "Schema.org url properties must be valid URIs"
    severity: error
    given: "$.url"
    then:
      function: pattern
      functionOptions:
        match: "^https?://"

  schema-org-same-as-format:
    description: sameAs references should be valid URIs
    message: "sameAs links should be valid URIs pointing to authoritative references"
    severity: warn
    given: "$.sameAs"
    then:
      function: pattern
      functionOptions:
        match: "^https?://"

  schema-org-aggregate-rating-values:
    description: AggregateRating must include ratingValue
    message: "AggregateRating should include ratingValue, ratingCount, and bestRating"
    severity: warn
    given: "$[?(@type == 'AggregateRating')]"
    then:
      field: ratingValue
      function: truthy

  schema-org-offer-price-currency:
    description: Offers must include both price and priceCurrency
    message: "Offer objects must include both price and priceCurrency properties"
    severity: error
    given: "$[?(@type == 'Offer')]"
    then:
      field: priceCurrency
      function: truthy

  schema-org-webapi-documentation:
    description: WebAPI types should include documentation URL
    message: "WebAPI structured data should include a documentation URL"
    severity: warn
    given: "$[?(@type == 'WebAPI')]"
    then:
      field: documentation
      function: truthy

  schema-org-organization-url:
    description: Organization entities should include a URL
    message: "Organization type should include a url property"
    severity: warn
    given: "$[?(@type == 'Organization')]"
    then:
      field: url
      function: truthy

  schema-org-person-name:
    description: Person entities must include a name
    message: "Person type must include a name property"
    severity: error
    given: "$[?(@type == 'Person')]"
    then:
      field: name
      function: truthy