Last.fm · API Governance Rules

Last.fm API Rules

Spectral linting rules defining API design standards and conventions for Last.fm.

13 Rules error 6 warn 4 info 3
View Rules File View on GitHub

Rule Categories

lastfm

Rules

error
lastfm-operation-ids-required
All operations must have an operationId.
$.paths[*][get,post,put,patch,delete]
error
lastfm-operation-summary-required
All operations must have a summary.
$.paths[*][get,post,put,patch,delete]
warn
lastfm-operation-summary-title-case
Operation summaries should use Title Case.
$.paths[*][get,post,put,patch,delete].summary
error
lastfm-tags-required
All operations must have at least one tag.
$.paths[*][get,post,put,patch,delete]
warn
lastfm-api-key-required
All read operations should accept the api_key parameter.
$.paths[?(@property.match(/method=/))].get.parameters[*]
warn
lastfm-method-name-convention
Method names should follow `package.methodName` naming (camelCase method).
$.paths[*]
error
lastfm-write-operations-require-post
Write methods (addTags, removeTag, scrobble, love, unlove, updateNowPlaying, getSession, getMobileSession) must use POST.
$.paths[?(@property.match(/addTags|removeTag|scrobble|love|unlove|updateNowPlaying|getMobileSession/))]
error
lastfm-response-200-required
All operations must document a 200 response.
$.paths[*][get,post,put,patch,delete]
info
lastfm-error-codes-documented
Documented Last.fm numeric error codes should be referenced in descriptions.
$.components.schemas.ErrorPayload.properties.error.description
info
lastfm-rate-limit-documented
API description should mention the 5 req/sec/origin rate guidance.
$.info.description
error
lastfm-security-defined
API must define ApiKeyAuth and SignedAuth security schemes.
$.components.securitySchemes
warn
lastfm-base-url-canonical
Primary server URL must be https://ws.audioscrobbler.com/2.0.
$.servers[0].url
info
lastfm-format-param-json
Operations should support format=json via the format query parameter.
$.components.parameters.FormatParam.schema.enum

Spectral Ruleset

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

  lastfm-operation-summary-required:
    description: All operations must have a summary.
    severity: error
    given: "$.paths[*][get,post,put,patch,delete]"
    then:
      field: summary
      function: truthy

  lastfm-operation-summary-title-case:
    description: Operation summaries should use Title Case.
    severity: warn
    given: "$.paths[*][get,post,put,patch,delete].summary"
    then:
      function: pattern
      functionOptions:
        match: "^([A-Z][a-zA-Z0-9]*)(\\s+([A-Z][a-zA-Z0-9]*|For|By|To|And|Or|Of|The|A|An))*$"

  lastfm-tags-required:
    description: All operations must have at least one tag.
    severity: error
    given: "$.paths[*][get,post,put,patch,delete]"
    then:
      field: tags
      function: truthy

  lastfm-api-key-required:
    description: All read operations should accept the api_key parameter.
    severity: warn
    given: "$.paths[?(@property.match(/method=/))].get.parameters[*]"
    then:
      function: defined

  lastfm-method-name-convention:
    description: Method names should follow `package.methodName` naming (camelCase method).
    severity: warn
    given: "$.paths[*]"
    then:
      function: pattern
      functionOptions:
        match: "^/\\?method=[a-z]+\\.[a-zA-Z]+$|^/$"

  lastfm-write-operations-require-post:
    description: Write methods (addTags, removeTag, scrobble, love, unlove, updateNowPlaying, getSession, getMobileSession) must use POST.
    severity: error
    given: "$.paths[?(@property.match(/addTags|removeTag|scrobble|love|unlove|updateNowPlaying|getMobileSession/))]"
    then:
      field: post
      function: truthy

  lastfm-response-200-required:
    description: All operations must document a 200 response.
    severity: error
    given: "$.paths[*][get,post,put,patch,delete]"
    then:
      field: responses.200
      function: truthy

  lastfm-error-codes-documented:
    description: Documented Last.fm numeric error codes should be referenced in descriptions.
    severity: info
    given: "$.components.schemas.ErrorPayload.properties.error.description"
    then:
      function: truthy

  lastfm-rate-limit-documented:
    description: API description should mention the 5 req/sec/origin rate guidance.
    severity: info
    given: "$.info.description"
    then:
      function: truthy

  lastfm-security-defined:
    description: API must define ApiKeyAuth and SignedAuth security schemes.
    severity: error
    given: "$.components.securitySchemes"
    then:
      function: truthy

  lastfm-base-url-canonical:
    description: Primary server URL must be https://ws.audioscrobbler.com/2.0.
    severity: warn
    given: "$.servers[0].url"
    then:
      function: pattern
      functionOptions:
        match: "^https://ws\\.audioscrobbler\\.com/2\\.0$"

  lastfm-format-param-json:
    description: Operations should support format=json via the format query parameter.
    severity: info
    given: "$.components.parameters.FormatParam.schema.enum"
    then:
      function: schema
      functionOptions:
        schema:
          type: array
          contains:
            const: json