Warner Music Group · API Governance Rules

Warner Music Group API Rules

Spectral linting rules defining API design standards and conventions for Warner Music Group.

10 Rules error 6 warn 3 info 1
View Rules File View on GitHub

Rule Categories

wmg

Rules

error
wmg-operation-ids-required
All operations must have an operationId
$.paths[*][*]
warn
wmg-operation-summary-title-case
Operation summaries must use Title Case
$.paths[*][*].summary
error
wmg-operation-tags-required
All operations must have at least one tag
$.paths[*][*]
error
wmg-paths-versioned
All API paths must include a version prefix
$.paths
error
wmg-oauth2-required
WMG API uses OAuth2 authentication
$.components.securitySchemes
error
wmg-response-success-defined
Operations must define a successful response
$.paths[*][*].responses
warn
wmg-response-401-defined
Protected operations must define a 401 response
$.paths[*][*].responses
error
wmg-catalog-search-params
Catalog search must have at least a query parameter
$.paths['/v1/catalog/search'].get.parameters
info
wmg-isrc-path-pattern
Track endpoints should use ISRC as the path parameter
$.paths./v1/tracks/{isrc}.get.parameters[*]
warn
wmg-pagination-on-lists
List operations should support limit and offset parameters
$.paths[*].get.parameters[*].name

Spectral Ruleset

Raw ↑
extends: spectral:oas
rules:
  wmg-operation-ids-required:
    description: All operations must have an operationId
    severity: error
    given: "$.paths[*][*]"
    then:
      field: operationId
      function: truthy

  wmg-operation-summary-title-case:
    description: Operation summaries must use Title Case
    severity: warn
    given: "$.paths[*][*].summary"
    then:
      function: pattern
      functionOptions:
        match: "^[A-Z][a-zA-Z0-9]*(\\s[A-Z][a-zA-Z0-9]*)*$"

  wmg-operation-tags-required:
    description: All operations must have at least one tag
    severity: error
    given: "$.paths[*][*]"
    then:
      field: tags
      function: truthy

  wmg-paths-versioned:
    description: All API paths must include a version prefix
    severity: error
    given: "$.paths"
    then:
      function: pattern
      functionOptions:
        match: "^\\/v[0-9]+"

  wmg-oauth2-required:
    description: WMG API uses OAuth2 authentication
    severity: error
    given: "$.components.securitySchemes"
    then:
      function: schema
      functionOptions:
        schema:
          type: object
          minProperties: 1

  wmg-response-success-defined:
    description: Operations must define a successful response
    severity: error
    given: "$.paths[*][*].responses"
    then:
      function: schema
      functionOptions:
        schema:
          type: object
          anyOf:
            - required: ["200"]
            - required: ["201"]

  wmg-response-401-defined:
    description: Protected operations must define a 401 response
    severity: warn
    given: "$.paths[*][*].responses"
    then:
      function: schema
      functionOptions:
        schema:
          type: object
          required:
            - "401"

  wmg-catalog-search-params:
    description: Catalog search must have at least a query parameter
    severity: error
    given: "$.paths['/v1/catalog/search'].get.parameters"
    then:
      function: truthy

  wmg-isrc-path-pattern:
    description: Track endpoints should use ISRC as the path parameter
    severity: info
    given: "$.paths./v1/tracks/{isrc}.get.parameters[*]"
    then:
      function: schema
      functionOptions:
        schema:
          type: object
          properties:
            name:
              enum:
                - isrc

  wmg-pagination-on-lists:
    description: List operations should support limit and offset parameters
    severity: warn
    given: "$.paths[*].get.parameters[*].name"
    then:
      function: enumeration
      functionOptions:
        values:
          - limit
          - offset
          - page
          - cursor