Ampersand · API Governance Rules

Ampersand API Rules

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

31 Rules error 15 warn 13 info 3
View Rules File View on GitHub

Rule Categories

delete examples get info no openapi operation parameter path paths query request response schema security servers tags

Rules

warn
info-title-prefix
API title should reference "Ampersand".
$.info.title
error
info-description-required
API info must have a description.
$.info
error
info-version-required
API info must define a version.
$.info
error
openapi-version-3
OpenAPI version must be 3.0.x or 3.1.x.
$.openapi
error
servers-defined
At least one server must be defined.
$
error
servers-https
Server URLs must use HTTPS.
$.servers[*].url
warn
paths-kebab-case
Path segments should use kebab-case or camelCase with braces for params.
$.paths[*]~
error
paths-no-trailing-slash
Paths must not have trailing slashes.
$.paths[*]~
error
operation-summary-required
Every operation must have a summary.
$.paths[*][get,post,put,patch,delete,head,options]
warn
operation-summary-prefix
Operation summaries should start with "Ampersand".
$.paths[*][get,post,put,patch,delete,head,options].summary
warn
operation-description-required
Every operation should have a description.
$.paths[*][get,post,put,patch,delete,head,options]
error
operation-id-required
Every operation must have an operationId.
$.paths[*][get,post,put,patch,delete,head,options]
warn
operation-id-camel-case
operationId should use camelCase.
$.paths[*][get,post,put,patch,delete,head,options].operationId
error
operation-tags-required
Every operation must have at least one tag.
$.paths[*][get,post,put,patch,delete,head,options]
warn
tags-global-defined
Global tags array should be defined.
$
error
parameter-description-required
Every parameter must have a description.
$.paths[*][*].parameters[*]
warn
request-body-json-content-type
Request bodies should use application/json content type.
$.paths[*][post,put,patch].requestBody.content
error
response-success-required
Every operation must define responses.
$.paths[*][get,post,put,patch,delete]
warn
response-401-required
Operations should document a 401 unauthorized response.
$.paths[*][get,post,put,patch,delete].responses
error
response-description-required
Every response must have a description.
$.paths[*][*].responses[*]
warn
schema-description-required
Top-level schemas should have a description.
$.components.schemas[*]
error
security-scheme-defined
Security schemes must be defined in components.
$.components
error
get-no-request-body
GET operations must not have a request body.
$.paths[*].get
info
delete-returns-204
DELETE operations should return 204 No Content when successful.
$.paths[*].delete.responses
error
no-empty-descriptions
Descriptions must not be empty strings.
$..description
info
examples-encouraged
Operations should include examples for documentation.
$.paths[*][*].responses[*].content[*]
warn
servers-expected-domain
Server URLs should be on the withampersand.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 camelCase (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 camelCase (the dominant convention in this API).
$.components.schemas[*].properties

Spectral Ruleset

Raw ↑
# ampersand — 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: 1/1 servers on withampersand.com
#   - path-params-casing: camel @ 95% (n=120)
#   - query-params-casing: camel @ 70% (n=27)
#   - operationid-casing: camel @ 100% (n=81)
#   - schema-names-casing: pascal @ 100% (n=55)
#   - schema-properties-casing: camel @ 58% (n=253)
#   - security: global (root) — NOT emitting operation-security-required
#   - pagination params observed: ['pageSize', 'pageToken']
#   - merge: kept 26 existing, added 5 measured, upgraded 0
#   - added: servers-expected-domain, path-params-casing, query-params-casing, schema-names-casing, schema-properties-casing
extends:
  - spectral:oas
rules:
  info-title-prefix:
    description: API title should reference "Ampersand".
    severity: warn
    given: $.info.title
    then:
      function: pattern
      functionOptions:
        match: ^Ampersand
  info-description-required:
    description: API info must have a description.
    severity: error
    given: $.info
    then:
      field: description
      function: truthy
  info-version-required:
    description: API info must define a version.
    severity: error
    given: $.info
    then:
      field: version
      function: truthy
  openapi-version-3:
    description: OpenAPI version must be 3.0.x or 3.1.x.
    severity: error
    given: $.openapi
    then:
      function: pattern
      functionOptions:
        match: ^3\.
  servers-defined:
    description: At least one server must be defined.
    severity: error
    given: $
    then:
      field: servers
      function: truthy
  servers-https:
    description: Server URLs must use HTTPS.
    severity: error
    given: $.servers[*].url
    then:
      function: pattern
      functionOptions:
        match: ^https://
  paths-kebab-case:
    description: Path segments should use kebab-case or camelCase with braces for params.
    severity: warn
    given: $.paths[*]~
    then:
      function: pattern
      functionOptions:
        match: ^(/[a-z0-9A-Z{}_-]+)+$
  paths-no-trailing-slash:
    description: Paths must not have trailing slashes.
    severity: error
    given: $.paths[*]~
    then:
      function: pattern
      functionOptions:
        notMatch: /$
  operation-summary-required:
    description: Every operation must have a summary.
    severity: error
    given: $.paths[*][get,post,put,patch,delete,head,options]
    then:
      field: summary
      function: truthy
  operation-summary-prefix:
    description: Operation summaries should start with "Ampersand".
    severity: warn
    given: $.paths[*][get,post,put,patch,delete,head,options].summary
    then:
      function: pattern
      functionOptions:
        match: ^Ampersand
  operation-description-required:
    description: Every operation should have a description.
    severity: warn
    given: $.paths[*][get,post,put,patch,delete,head,options]
    then:
      field: description
      function: truthy
  operation-id-required:
    description: Every operation must have an operationId.
    severity: error
    given: $.paths[*][get,post,put,patch,delete,head,options]
    then:
      field: operationId
      function: truthy
  operation-id-camel-case:
    description: operationId should use camelCase.
    severity: warn
    given: $.paths[*][get,post,put,patch,delete,head,options].operationId
    then:
      function: pattern
      functionOptions:
        match: ^[a-z][a-zA-Z0-9]*$
  operation-tags-required:
    description: Every operation must have at least one tag.
    severity: error
    given: $.paths[*][get,post,put,patch,delete,head,options]
    then:
      field: tags
      function: truthy
  tags-global-defined:
    description: Global tags array should be defined.
    severity: warn
    given: $
    then:
      field: tags
      function: truthy
  parameter-description-required:
    description: Every parameter must have a description.
    severity: error
    given: $.paths[*][*].parameters[*]
    then:
      field: description
      function: truthy
  request-body-json-content-type:
    description: Request bodies should use application/json content type.
    severity: warn
    given: $.paths[*][post,put,patch].requestBody.content
    then:
      field: application/json
      function: truthy
  response-success-required:
    description: Every operation must define responses.
    severity: error
    given: $.paths[*][get,post,put,patch,delete]
    then:
      field: responses
      function: truthy
  response-401-required:
    description: Operations should document a 401 unauthorized response.
    severity: warn
    given: $.paths[*][get,post,put,patch,delete].responses
    then:
      field: '401'
      function: truthy
  response-description-required:
    description: Every response must have a description.
    severity: error
    given: $.paths[*][*].responses[*]
    then:
      field: description
      function: truthy
  schema-description-required:
    description: Top-level schemas should have a description.
    severity: warn
    given: $.components.schemas[*]
    then:
      field: description
      function: truthy
  security-scheme-defined:
    description: Security schemes must be defined in components.
    severity: error
    given: $.components
    then:
      field: securitySchemes
      function: truthy
  get-no-request-body:
    description: GET operations must not have a request body.
    severity: error
    given: $.paths[*].get
    then:
      field: requestBody
      function: falsy
  delete-returns-204:
    description: DELETE operations should return 204 No Content when successful.
    severity: info
    given: $.paths[*].delete.responses
    then:
      field: '204'
      function: truthy
  no-empty-descriptions:
    description: Descriptions must not be empty strings.
    severity: error
    given: $..description
    then:
      function: pattern
      functionOptions:
        match: .+
  examples-encouraged:
    description: Operations should include examples for documentation.
    severity: info
    given: $.paths[*][*].responses[*].content[*]
    then:
      field: examples
      function: truthy
  servers-expected-domain:
    description: Server URLs should be on the withampersand.com domain.
    severity: warn
    given: $.servers[*].url
    then:
      function: pattern
      functionOptions:
        match: withampersand\.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 camelCase (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: camel
  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: pattern
      functionOptions:
        match: ^[A-Z][A-Za-z0-9]*$
  schema-properties-casing:
    description: Schema properties should be camelCase (the dominant convention in this API).
    severity: info
    given: $.components.schemas[*].properties
    then:
      field: '@key'
      function: casing
      functionOptions:
        type: camel