Amnic · API Governance Rules

Amnic API Rules

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

34 Rules error 15 warn 18 info 1
View Rules File View on GitHub

Rule Categories

error examples get info no openapi operation parameter paths request response schema security servers tags

Rules

warn
info-title-prefix
API title should start with "Amnic".
$.info.title
error
info-description-required
API info must have a description of at least 20 characters.
$.info
error
info-version-required
API info must define a version.
$.info
warn
info-contact-required
API info should include contact information.
$.info
error
openapi-version-3
OpenAPI version must be 3.0.x.
$.openapi
error
servers-defined
At least one server must be defined.
$
error
servers-https
Server URLs must use HTTPS.
$.servers[*].url
warn
servers-description
Each server should have a description.
$.servers[*]
warn
paths-kebab-case
Path segments should use kebab-case (lowercase with hyphens).
$.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 "Amnic".
$.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.
$
warn
tags-description
Global tags should have descriptions.
$.tags[*]
error
parameter-description-required
Every parameter must have a description.
$.paths[*][*].parameters[*]
warn
parameter-snake-case
Query and path parameter names should use snake_case or kebab-case.
$.paths[*][*].parameters[?(@.in == 'query')].name
warn
request-body-content-type
Request bodies should use application/json content type.
$.paths[*][post,put,patch].requestBody.content
error
response-success-required
Every operation must have at least one 2xx response.
$.paths[*][get,post,put,patch,delete]
warn
response-401-required
Operations with security should document a 401 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[*]
warn
schema-property-snake-case
Schema property names should use snake_case.
$.components.schemas[*].properties[*]~
error
security-scheme-defined
Security schemes must be defined in components.
$.components
warn
security-global-defined
Global security should be defined.
$
error
get-no-request-body
GET operations must not have a request body.
$.paths[*].get
error
no-empty-descriptions
Descriptions must not be empty strings.
$..description
info
examples-encouraged
Operations should include examples for better documentation.
$.paths[*][*].responses[*].content[*]
warn
servers-expected-domain
Server URLs should be on the amnic.com domain.
$.servers[*].url
warn
schema-names-casing
Component schema names should be PascalCase (the dominant convention in this API).
$.components.schemas
warn
error-schema-defined
A shared error schema (ErrorResponse) should be defined for error payloads.
$.components.schemas

Spectral Ruleset

Raw ↑
# amnic — 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 amnic.com
#   - schema-names-casing: pascal @ 100% (n=5)
#   - security: global (root) — NOT emitting operation-security-required
#   - error-schema-defined: ErrorResponse
#   - merge: kept 31 existing, added 3 measured, upgraded 0
#   - added: servers-expected-domain, schema-names-casing, error-schema-defined
extends:
  - spectral:oas
rules:
  info-title-prefix:
    description: API title should start with "Amnic".
    severity: warn
    given: $.info.title
    then:
      function: pattern
      functionOptions:
        match: ^Amnic
  info-description-required:
    description: API info must have a description of at least 20 characters.
    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
  info-contact-required:
    description: API info should include contact information.
    severity: warn
    given: $.info
    then:
      field: contact
      function: truthy
  openapi-version-3:
    description: OpenAPI version must be 3.0.x.
    severity: error
    given: $.openapi
    then:
      function: pattern
      functionOptions:
        match: ^3\.0\.
  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://
  servers-description:
    description: Each server should have a description.
    severity: warn
    given: $.servers[*]
    then:
      field: description
      function: truthy
  paths-kebab-case:
    description: Path segments should use kebab-case (lowercase with hyphens).
    severity: warn
    given: $.paths[*]~
    then:
      function: pattern
      functionOptions:
        match: ^(/[a-z0-9{}-]+)+$
  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 "Amnic".
    severity: warn
    given: $.paths[*][get,post,put,patch,delete,head,options].summary
    then:
      function: pattern
      functionOptions:
        match: ^Amnic
  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
  tags-description:
    description: Global tags should have descriptions.
    severity: warn
    given: $.tags[*]
    then:
      field: description
      function: truthy
  parameter-description-required:
    description: Every parameter must have a description.
    severity: error
    given: $.paths[*][*].parameters[*]
    then:
      field: description
      function: truthy
  parameter-snake-case:
    description: Query and path parameter names should use snake_case or kebab-case.
    severity: warn
    given: $.paths[*][*].parameters[?(@.in == 'query')].name
    then:
      function: pattern
      functionOptions:
        match: ^[a-z][a-z0-9_]*$
  request-body-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 have at least one 2xx response.
    severity: error
    given: $.paths[*][get,post,put,patch,delete]
    then:
      field: responses
      function: truthy
  response-401-required:
    description: Operations with security should document a 401 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
  schema-property-snake-case:
    description: Schema property names should use snake_case.
    severity: warn
    given: $.components.schemas[*].properties[*]~
    then:
      function: pattern
      functionOptions:
        match: ^[a-z][a-z0-9_]*$
  security-scheme-defined:
    description: Security schemes must be defined in components.
    severity: error
    given: $.components
    then:
      field: securitySchemes
      function: truthy
  security-global-defined:
    description: Global security should be defined.
    severity: warn
    given: $
    then:
      field: security
      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
  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 better documentation.
    severity: info
    given: $.paths[*][*].responses[*].content[*]
    then:
      field: examples
      function: truthy
  servers-expected-domain:
    description: Server URLs should be on the amnic.com domain.
    severity: warn
    given: $.servers[*].url
    then:
      function: pattern
      functionOptions:
        match: amnic\.com
  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
  error-schema-defined:
    description: A shared error schema (ErrorResponse) should be defined for error payloads.
    severity: warn
    given: $.components.schemas
    then:
      field: ErrorResponse
      function: truthy