Discogs · API Governance Rules

Discogs API Rules

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

35 Rules error 11 warn 19 info 5
View Rules File View on GitHub

Rule Categories

http info openapi operation parameter paths request response schema security server tags

Rules

warn
info-discogs-title
Info title should match Discogs naming pattern.
$.info.title
error
info-description-required
Info description is required.
$.info
error
info-version-required
Info version is required.
$.info
warn
info-contact-required
Info should declare contact.
$.info
warn
info-license-required
Info should declare license.
$.info
error
openapi-version-3
OpenAPI version must be 3.x.
$
error
server-https-required
Servers must use HTTPS.
$.servers[*].url
error
server-discogs-host
Server URL must be on api.discogs.com.
$.servers[*].url
warn
paths-snake-case
Path segments use snake_case (Discogs convention).
$.paths[*]~
warn
paths-no-trailing-slash
No trailing slashes on paths.
$.paths[*]~
error
operation-operationid-required
Operations must have an operationId.
$.paths[*][get,post,put,patch,delete]
warn
operation-operationid-camelcase
operationId must be camelCase.
$.paths[*][get,post,put,patch,delete].operationId
error
operation-summary-required
Operations must have a summary.
$.paths[*][get,post,put,patch,delete]
warn
operation-summary-discogs-prefix
Operation summary should start with "Discogs".
$.paths[*][get,post,put,patch,delete].summary
warn
operation-description-required
Operations must have a description.
$.paths[*][get,post,put,patch,delete]
error
operation-tags-required
Operations must declare tags.
$.paths[*][get,post,put,patch,delete]
warn
tags-global-defined
Global tags array must be defined.
$
warn
tags-title-case
Tag names should be Title Case.
$.tags[*].name
warn
parameter-description-required
Parameters must have a description.
$.paths[*][get,post,put,patch,delete].parameters[*]
warn
parameter-snake-case
Parameter names should be snake_case.
$.paths[*][get,post,put,patch,delete].parameters[?(@.in!="path")].name
info
parameter-pagination-page-perpage
Use page + per_page for pagination (Discogs convention).
$.paths[*][get].parameters[?(@.in=="query")].name
warn
request-body-json
Request bodies must use application/json.
$.paths[*][post,put,patch].requestBody.content
error
response-success-required
Operations must define a 2xx response.
$.paths[*][get,post,put,patch,delete].responses
info
response-401-on-secured
Secured operations should declare a 401 response.
$.paths[*][post,put,patch,delete].responses
warn
response-json-content
Responses should be application/json.
$.paths[*][get,post,put,patch,delete].responses[2,3]??.content
warn
schema-property-snake-case
Schema property names should be snake_case (Discogs convention).
$.components.schemas[*].properties[*]~
warn
schema-type-required
Schemas must declare a type.
$.components.schemas[?([email protected] && [email protected] && [email protected] && !@.$ref)]
info
schema-description-encouraged
Top-level schemas should have a description.
$.components.schemas[*]
error
security-schemes-defined
Security schemes must be declared in components.
$.components
warn
security-global-required
Global security should be declared.
$
error
http-get-no-body
GET operations must not have a request body.
$.paths[*].get
warn
http-delete-no-body
DELETE operations should not have a request body.
$.paths[*].delete
info
operation-x-microcks-required
Operations should declare x-microcks-operation for mock-server compatibility.
$.paths[*][get,post,put,patch,delete]
info
operation-rate-limit-documented
Document the 60 req/min (auth) / 25 req/min (unauth) Discogs rate limits in info.description.
$.info.description
warn
operation-user-agent-required
Document the mandatory unique User-Agent requirement in info.description.
$.info.description

Spectral Ruleset

Raw ↑
extends:
- - spectral:oas
  - recommended
rules:
  info-discogs-title:
    description: Info title should match Discogs naming pattern.
    message: Info title should start with "Discogs"
    severity: warn
    given: $.info.title
    then:
      function: pattern
      functionOptions:
        match: ^Discogs
  info-description-required:
    description: Info description is required.
    severity: error
    given: $.info
    then:
      field: description
      function: truthy
  info-version-required:
    description: Info version is required.
    severity: error
    given: $.info
    then:
      field: version
      function: truthy
  info-contact-required:
    description: Info should declare contact.
    severity: warn
    given: $.info
    then:
      field: contact
      function: truthy
  info-license-required:
    description: Info should declare license.
    severity: warn
    given: $.info
    then:
      field: license
      function: truthy
  openapi-version-3:
    description: OpenAPI version must be 3.x.
    severity: error
    given: $
    then:
      field: openapi
      function: pattern
      functionOptions:
        match: ^3\.
  server-https-required:
    description: Servers must use HTTPS.
    severity: error
    given: $.servers[*].url
    then:
      function: pattern
      functionOptions:
        match: ^https://
  server-discogs-host:
    description: Server URL must be on api.discogs.com.
    severity: error
    given: $.servers[*].url
    then:
      function: pattern
      functionOptions:
        match: api\.discogs\.com
  paths-snake-case:
    description: Path segments use snake_case (Discogs convention).
    severity: warn
    given: $.paths[*]~
    then:
      function: pattern
      functionOptions:
        match: ^(/(\{[a-z_]+\}|[a-z_]+))+$
  paths-no-trailing-slash:
    description: No trailing slashes on paths.
    severity: warn
    given: $.paths[*]~
    then:
      function: pattern
      functionOptions:
        notMatch: .+/$
  operation-operationid-required:
    description: Operations must have an operationId.
    severity: error
    given: $.paths[*][get,post,put,patch,delete]
    then:
      field: operationId
      function: truthy
  operation-operationid-camelcase:
    description: operationId must be camelCase.
    severity: warn
    given: $.paths[*][get,post,put,patch,delete].operationId
    then:
      function: pattern
      functionOptions:
        match: ^[a-z][a-zA-Z0-9]*$
  operation-summary-required:
    description: Operations must have a summary.
    severity: error
    given: $.paths[*][get,post,put,patch,delete]
    then:
      field: summary
      function: truthy
  operation-summary-discogs-prefix:
    description: Operation summary should start with "Discogs".
    severity: warn
    given: $.paths[*][get,post,put,patch,delete].summary
    then:
      function: pattern
      functionOptions:
        match: '^Discogs '
  operation-description-required:
    description: Operations must have a description.
    severity: warn
    given: $.paths[*][get,post,put,patch,delete]
    then:
      field: description
      function: truthy
  operation-tags-required:
    description: Operations must declare tags.
    severity: error
    given: $.paths[*][get,post,put,patch,delete]
    then:
      field: tags
      function: truthy
  tags-global-defined:
    description: Global tags array must be defined.
    severity: warn
    given: $
    then:
      field: tags
      function: truthy
  tags-title-case:
    description: Tag names should be Title Case.
    severity: warn
    given: $.tags[*].name
    then:
      function: pattern
      functionOptions:
        match: ^[A-Z][A-Za-z0-9]*( [A-Z][A-Za-z0-9]*)*$
  parameter-description-required:
    description: Parameters must have a description.
    severity: warn
    given: $.paths[*][get,post,put,patch,delete].parameters[*]
    then:
      field: description
      function: truthy
  parameter-snake-case:
    description: Parameter names should be snake_case.
    severity: warn
    given: $.paths[*][get,post,put,patch,delete].parameters[?(@.in!="path")].name
    then:
      function: pattern
      functionOptions:
        match: ^[a-z][a-z0-9_]*$
  parameter-pagination-page-perpage:
    description: Use page + per_page for pagination (Discogs convention).
    severity: info
    given: $.paths[*][get].parameters[?(@.in=="query")].name
    then:
      function: pattern
      functionOptions:
        notMatch: ^(offset|limit|cursor)$
  request-body-json:
    description: Request bodies must use application/json.
    severity: warn
    given: $.paths[*][post,put,patch].requestBody.content
    then:
      field: application/json
      function: truthy
  response-success-required:
    description: Operations must define a 2xx response.
    severity: error
    given: $.paths[*][get,post,put,patch,delete].responses
    then:
      function: truthy
  response-401-on-secured:
    description: Secured operations should declare a 401 response.
    severity: info
    given: $.paths[*][post,put,patch,delete].responses
    then:
      field: '401'
      function: truthy
  response-json-content:
    description: Responses should be application/json.
    severity: warn
    given: $.paths[*][get,post,put,patch,delete].responses[2,3]??.content
    then:
      field: application/json
      function: truthy
  schema-property-snake-case:
    description: Schema property names should be snake_case (Discogs convention).
    severity: warn
    given: $.components.schemas[*].properties[*]~
    then:
      function: pattern
      functionOptions:
        match: ^[a-z][a-z0-9_]*$
  schema-type-required:
    description: Schemas must declare a type.
    severity: warn
    given: $.components.schemas[?([email protected] && [email protected] && [email protected] && !@.$ref)]
    then:
      field: type
      function: truthy
  schema-description-encouraged:
    description: Top-level schemas should have a description.
    severity: info
    given: $.components.schemas[*]
    then:
      field: description
      function: truthy
  security-schemes-defined:
    description: Security schemes must be declared in components.
    severity: error
    given: $.components
    then:
      field: securitySchemes
      function: truthy
  security-global-required:
    description: Global security should be declared.
    severity: warn
    given: $
    then:
      field: security
      function: truthy
  http-get-no-body:
    description: GET operations must not have a request body.
    severity: error
    given: $.paths[*].get
    then:
      field: requestBody
      function: falsy
  http-delete-no-body:
    description: DELETE operations should not have a request body.
    severity: warn
    given: $.paths[*].delete
    then:
      field: requestBody
      function: falsy
  operation-x-microcks-required:
    description: Operations should declare x-microcks-operation for mock-server compatibility.
    severity: info
    given: $.paths[*][get,post,put,patch,delete]
    then:
      field: x-microcks-operation
      function: truthy
  operation-rate-limit-documented:
    description: Document the 60 req/min (auth) / 25 req/min (unauth) Discogs rate limits in info.description.
    severity: info
    given: $.info.description
    then:
      function: pattern
      functionOptions:
        match: Rate Limiting
  operation-user-agent-required:
    description: Document the mandatory unique User-Agent requirement in info.description.
    severity: warn
    given: $.info.description
    then:
      function: pattern
      functionOptions:
        match: User-Agent