Unity · API Governance Rules

Unity API Rules

Spectral linting rules defining API design standards and conventions for Unity.

23 Rules error 8 warn 12 info 2
View Rules File View on GitHub

Rule Categories

no path query schema servers unity

Rules

error
unity-paths-start-with-version
All Unity API paths must start with a version prefix (e.g., /v1/, /v2/, /v3/)
$.paths[*]~
warn
unity-paths-use-kebab-case
Unity API path segments must use kebab-case (lowercase with hyphens)
$.paths[*]~
error
unity-no-trailing-slash
Paths must not have a trailing slash
$.paths[*]~
hint
unity-project-environment-paths
Paths that contain projectId or environmentId must include both
$.paths[*]~
error
unity-operation-id-format
Operation IDs must use camelCase
$.paths[*][*].operationId
error
unity-operation-id-required
All Unity API operations must have an operationId
$.paths[*][*]
error
unity-success-response-required
All operations must document at least one 2xx success response
$.paths[*][*].responses
warn
unity-401-response-on-secured-endpoints
Protected Unity endpoints should document 401 Unauthorized responses
$.paths[*][post,put,patch,delete].responses
info
unity-bearer-auth-scheme
Unity APIs use Bearer JWT tokens for authentication
$.components.securitySchemes[*]
error
unity-info-description
API info must include a description
$.info
warn
unity-info-version
API must have a version in semver-like format
$.info.version
warn
unity-external-docs
Unity APIs should link to their documentation pages
$
warn
unity-response-schema-defined
All 2xx responses should have defined schemas
$.paths[*][*].responses[?(@property.match(/^2/))].content.application/json
warn
unity-parameters-have-description
All path and query parameters should have descriptions
$.paths[*][*].parameters[?(@.in == 'path' || @.in == 'query')]
error
unity-operations-have-tags
All Unity operations must be tagged for grouping in documentation
$.paths[*][*]
warn
unity-tags-title-case
Unity API tags must use Title Case
$.paths[*][*].tags[*]
error
servers-https-only
Server URLs must use HTTPS.
$.servers[*].url
warn
servers-expected-domain
Server URLs should be on the unity.com domain.
$.servers[*].url
warn
path-params-casing
Path parameters should be camelCase (the dominant convention in this API).
$.paths[*].parameters[?(@.in=='path')].name
warn
query-params-casing
Query parameters should be snake_case (the dominant convention in this API).
$.paths[*][get,post,put,patch,delete].parameters[?(@.in=='query')]
warn
schema-names-casing
Component schema names should be PascalCase (the dominant convention in this API).
$.components.schemas
info
schema-properties-casing
Schema properties should be snake_case (the dominant convention in this API).
$.components.schemas[*].properties
warn
no-empty-descriptions
Descriptions must not be empty strings.
$..description

Spectral Ruleset

Raw ↑
# unity — Spectral ruleset (strengthened)
# Plain Spectral. Existing hand-authored rules preserved; measured rules added
# from this provider's own OpenAPI conventions by strengthen_ruleset.py,
# then self-validated against the spec.
#
# Provenance:
#   - servers-https-only: 100% of servers already https (error)
#   - servers-expected-domain: 11/13 servers on unity.com
#   - path-params-casing: camel @ 85% (n=191)
#   - query-params-casing: snake @ 85% (n=20)
#   - operationid-casing: camel @ 100% (n=98)
#   - schema-names-casing: pascal @ 100% (n=106)
#   - schema-properties-casing: snake @ 69% (n=368)
#   - security: global (root) — NOT emitting operation-security-required
#   - pagination params observed: ['cursor', 'limit', 'offset', 'page', 'per_page']
#   - merge: kept 16 existing, added 7 measured, upgraded 0
#   - added: servers-https-only, servers-expected-domain, path-params-casing, query-params-casing, schema-names-casing, schema-properties-casing, no-empty-descriptions
extends:
  - spectral:oas
rules:
  unity-paths-start-with-version:
    description: All Unity API paths must start with a version prefix (e.g., /v1/, /v2/, /v3/)
    message: Path '{{property}}' must start with a version prefix like /v1/
    severity: error
    given: $.paths[*]~
    then:
      function: pattern
      functionOptions:
        match: ^/v[0-9]+
  unity-paths-use-kebab-case:
    description: Unity API path segments must use kebab-case (lowercase with hyphens)
    message: Path '{{property}}' must use kebab-case for all segments
    severity: warn
    given: $.paths[*]~
    then:
      function: pattern
      functionOptions:
        notMatch: '[A-Z_]'
  unity-no-trailing-slash:
    description: Paths must not have a trailing slash
    message: Path '{{property}}' must not have a trailing slash
    severity: error
    given: $.paths[*]~
    then:
      function: pattern
      functionOptions:
        notMatch: /$
  unity-project-environment-paths:
    description: Paths that contain projectId or environmentId must include both
    message: Paths with projectId should also include environmentId for proper scoping
    severity: hint
    given: $.paths[*]~
    then:
      function: pattern
      functionOptions:
        notMatch: \{projectId\}(?!.*(?:\{environmentId\}|builds|buildtargets))
  unity-operation-id-format:
    description: Operation IDs must use camelCase
    message: Operation ID '{{value}}' must be camelCase
    severity: error
    given: $.paths[*][*].operationId
    then:
      function: pattern
      functionOptions:
        match: ^[a-z][a-zA-Z0-9]*$
  unity-operation-id-required:
    description: All Unity API operations must have an operationId
    message: Operation must have an operationId for SDK generation compatibility
    severity: error
    given: $.paths[*][*]
    then:
      field: operationId
      function: truthy
  unity-success-response-required:
    description: All operations must document at least one 2xx success response
    message: Operation must have at least one 2xx response code
    severity: error
    given: $.paths[*][*].responses
    then:
      function: schema
      functionOptions:
        schema:
          type: object
          minProperties: 1
  unity-401-response-on-secured-endpoints:
    description: Protected Unity endpoints should document 401 Unauthorized responses
    message: Secured endpoint should document 401 Unauthorized response
    severity: warn
    given: $.paths[*][post,put,patch,delete].responses
    then:
      function: defined
  unity-bearer-auth-scheme:
    description: Unity APIs use Bearer JWT tokens for authentication
    message: Security scheme should use HTTP Bearer authentication
    severity: info
    given: $.components.securitySchemes[*]
    then:
      function: schema
      functionOptions:
        schema:
          type: object
          properties:
            type:
              enum:
              - http
              - apiKey
            scheme:
              enum:
              - bearer
              - basic
  unity-info-description:
    description: API info must include a description
    message: API info must have a description explaining the service purpose
    severity: error
    given: $.info
    then:
      field: description
      function: truthy
  unity-info-version:
    description: API must have a version in semver-like format
    message: API version '{{value}}' should follow vX.Y.Z or vX format
    severity: warn
    given: $.info.version
    then:
      function: pattern
      functionOptions:
        match: ^v[0-9]
  unity-external-docs:
    description: Unity APIs should link to their documentation pages
    message: API should include externalDocs linking to Unity documentation
    severity: warn
    given: $
    then:
      field: externalDocs
      function: truthy
  unity-response-schema-defined:
    description: All 2xx responses should have defined schemas
    message: Response must include a content schema definition
    severity: warn
    given: $.paths[*][*].responses[?(@property.match(/^2/))].content.application/json
    then:
      field: schema
      function: defined
  unity-parameters-have-description:
    description: All path and query parameters should have descriptions
    message: Parameter '{{property}}' must have a description
    severity: warn
    given: $.paths[*][*].parameters[?(@.in == 'path' || @.in == 'query')]
    then:
      field: description
      function: truthy
  unity-operations-have-tags:
    description: All Unity operations must be tagged for grouping in documentation
    message: Operation must have at least one tag
    severity: error
    given: $.paths[*][*]
    then:
      field: tags
      function: truthy
  unity-tags-title-case:
    description: Unity API tags must use Title Case
    message: Tag '{{value}}' must use Title Case
    severity: warn
    given: $.paths[*][*].tags[*]
    then:
      function: pattern
      functionOptions:
        match: ^[A-Z][a-zA-Z0-9 ]*$
  servers-https-only:
    description: Server URLs must use HTTPS.
    severity: error
    given: $.servers[*].url
    then:
      function: pattern
      functionOptions:
        match: ^https://
  servers-expected-domain:
    description: Server URLs should be on the unity.com domain.
    severity: warn
    given: $.servers[*].url
    then:
      function: pattern
      functionOptions:
        match: unity\.com
  path-params-casing:
    description: Path parameters should be camelCase (the dominant convention in this API).
    severity: warn
    given: $.paths[*].parameters[?(@.in=='path')].name
    then:
      function: casing
      functionOptions:
        type: camel
  query-params-casing:
    description: Query parameters should be snake_case (the dominant convention in this API).
    severity: warn
    given: $.paths[*][get,post,put,patch,delete].parameters[?(@.in=='query')]
    then:
      field: name
      function: casing
      functionOptions:
        type: snake
  schema-names-casing:
    description: Component schema names should be PascalCase (the dominant convention in this API).
    severity: warn
    given: $.components.schemas
    then:
      field: '@key'
      function: casing
      functionOptions:
        type: pascal
  schema-properties-casing:
    description: Schema properties should be snake_case (the dominant convention in this API).
    severity: info
    given: $.components.schemas[*].properties
    then:
      field: '@key'
      function: casing
      functionOptions:
        type: snake
  no-empty-descriptions:
    description: Descriptions must not be empty strings.
    severity: warn
    given: $..description
    then:
      function: truthy