3M · API Governance Rules

3M API Rules

Spectral linting rules defining API design standards and conventions for 3M.

32 Rules error 13 warn 16 info 3
View Rules File View on GitHub

Rule Categories

delete get info no openapi operation parameter paths request response schema security servers tag

Rules

warn
info-title-pattern
API info title should follow "3M ..." pattern.
$.info.title
warn
info-description-required
API info description must be present and at least 50 characters.
$.info
error
info-version-required
API version must be defined.
$.info
error
openapi-version-3
Must use OpenAPI 3.x.
$
error
servers-must-be-defined
Servers array must be defined and non-empty.
$
error
servers-https-required
Production server URLs must use HTTPS.
$.servers[*]
warn
servers-description-required
Each server must have a description.
$.servers[*]
warn
paths-kebab-case
Path segments should use kebab-case or camelCase, not underscores.
$.paths
warn
paths-no-trailing-slash
Paths must not end with a trailing slash.
$.paths
error
operation-summary-required
Every operation must have a summary.
$.paths[*][get,post,put,patch,delete]
warn
operation-description-required
Every operation should have a description.
$.paths[*][get,post,put,patch,delete]
warn
operation-summary-prefix
Every summary should start with "3M".
$.paths[*][get,post,put,patch,delete].summary
error
operation-operationid-required
Every operation must have an operationId.
$.paths[*][get,post,put,patch,delete]
warn
operation-operationid-camelcase
OperationId should use camelCase.
$.paths[*][get,post,put,patch,delete].operationId
error
operation-tags-required
Every operation must have at least one tag.
$.paths[*][get,post,put,patch,delete]
warn
tag-description-required
Global tags must have descriptions.
$.tags[*]
warn
parameter-description-required
Every parameter must have a description.
$.paths[*][get,post,put,patch,delete].parameters[*]
error
parameter-schema-required
Every parameter must have a schema.
$.paths[*][get,post,put,patch,delete].parameters[*]
info
parameter-example-encouraged
Parameters should include example values.
$.paths[*][get,post,put,patch,delete].parameters[*]
warn
request-body-description
Request bodies should have a description.
$.paths[*][post,put,patch].requestBody
error
response-success-required
Every operation must define at least one success response.
$.paths[*][get,post,put,patch,delete].responses
error
response-description-required
Every response must have a description.
$.paths[*][get,post,put,patch,delete].responses[*]
error
response-401-required
Authenticated APIs must define 401 Unauthorized response.
$.paths[*][get,post,put,patch,delete].responses
warn
schema-description-required
Component schemas must have descriptions.
$.components.schemas[*]
warn
schema-type-required
Schemas should define a type.
$.components.schemas[*]
info
schema-properties-described
Schema properties should have descriptions.
$.components.schemas[*].properties[*]
info
schema-properties-examples
Schema properties should include example values.
$.components.schemas[*].properties[*]
error
security-schemes-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
warn
delete-no-request-body
DELETE operations should not have a request body.
$.paths[*].delete
warn
no-empty-descriptions
Descriptions must not be empty.
$..description

Spectral Ruleset

Raw ↑
rules:

  # INFO / METADATA
  info-title-pattern:
    description: API info title should follow "3M ..." pattern.
    severity: warn
    given: $.info.title
    then:
      function: pattern
      functionOptions:
        match: "^3M "

  info-description-required:
    description: API info description must be present and at least 50 characters.
    severity: warn
    given: $.info
    then:
      field: description
      function: minLength
      functionOptions:
        value: 50

  info-version-required:
    description: API version must be defined.
    severity: error
    given: $.info
    then:
      field: version
      function: truthy

  # OPENAPI VERSION
  openapi-version-3:
    description: Must use OpenAPI 3.x.
    severity: error
    given: $
    then:
      field: openapi
      function: pattern
      functionOptions:
        match: "^3\\."

  # SERVERS
  servers-must-be-defined:
    description: Servers array must be defined and non-empty.
    severity: error
    given: $
    then:
      field: servers
      function: truthy

  servers-https-required:
    description: Production server URLs must use HTTPS.
    severity: error
    given: $.servers[*]
    then:
      field: url
      function: pattern
      functionOptions:
        match: "^https://"

  servers-description-required:
    description: Each server must have a description.
    severity: warn
    given: $.servers[*]
    then:
      field: description
      function: truthy

  # PATHS — NAMING CONVENTIONS
  paths-kebab-case:
    description: Path segments should use kebab-case or camelCase, not underscores.
    severity: warn
    given: $.paths
    then:
      function: pattern
      functionOptions:
        notMatch: "_[a-z]"

  paths-no-trailing-slash:
    description: Paths must not end with a trailing slash.
    severity: warn
    given: $.paths
    then:
      function: pattern
      functionOptions:
        notMatch: "/$"

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

  operation-description-required:
    description: Every operation should have a description.
    severity: warn
    given: $.paths[*][get,post,put,patch,delete]
    then:
      field: description
      function: truthy

  operation-summary-prefix:
    description: Every summary should start with "3M".
    severity: warn
    given: $.paths[*][get,post,put,patch,delete].summary
    then:
      function: pattern
      functionOptions:
        match: "^3M "

  operation-operationid-required:
    description: Every operation must have an operationId.
    severity: error
    given: $.paths[*][get,post,put,patch,delete]
    then:
      field: operationId
      function: truthy

  operation-operationid-camelcase:
    description: OperationId should use camelCase.
    severity: warn
    given: $.paths[*][get,post,put,patch,delete].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]
    then:
      field: tags
      function: truthy

  # TAGS
  tag-description-required:
    description: Global tags must have descriptions.
    severity: warn
    given: $.tags[*]
    then:
      field: description
      function: truthy

  # PARAMETERS
  parameter-description-required:
    description: Every parameter must have a description.
    severity: warn
    given: $.paths[*][get,post,put,patch,delete].parameters[*]
    then:
      field: description
      function: truthy

  parameter-schema-required:
    description: Every parameter must have a schema.
    severity: error
    given: $.paths[*][get,post,put,patch,delete].parameters[*]
    then:
      field: schema
      function: truthy

  parameter-example-encouraged:
    description: Parameters should include example values.
    severity: info
    given: $.paths[*][get,post,put,patch,delete].parameters[*]
    then:
      field: example
      function: truthy

  # REQUEST BODIES
  request-body-description:
    description: Request bodies should have a description.
    severity: warn
    given: $.paths[*][post,put,patch].requestBody
    then:
      field: description
      function: truthy

  # RESPONSES
  response-success-required:
    description: Every operation must define at least one success response.
    severity: error
    given: $.paths[*][get,post,put,patch,delete].responses
    then:
      function: schema
      functionOptions:
        schema:
          type: object
          minProperties: 1

  response-description-required:
    description: Every response must have a description.
    severity: error
    given: $.paths[*][get,post,put,patch,delete].responses[*]
    then:
      field: description
      function: truthy

  response-401-required:
    description: Authenticated APIs must define 401 Unauthorized response.
    severity: error
    given: $.paths[*][get,post,put,patch,delete].responses
    then:
      function: schema
      functionOptions:
        schema:
          type: object
          properties:
            '401':
              type: object

  # SCHEMAS
  schema-description-required:
    description: Component schemas must have descriptions.
    severity: warn
    given: $.components.schemas[*]
    then:
      field: description
      function: truthy

  schema-type-required:
    description: Schemas should define a type.
    severity: warn
    given: $.components.schemas[*]
    then:
      field: type
      function: truthy

  schema-properties-described:
    description: Schema properties should have descriptions.
    severity: info
    given: $.components.schemas[*].properties[*]
    then:
      field: description
      function: truthy

  schema-properties-examples:
    description: Schema properties should include example values.
    severity: info
    given: $.components.schemas[*].properties[*]
    then:
      field: example
      function: truthy

  # SECURITY
  security-schemes-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

  # HTTP METHOD CONVENTIONS
  get-no-request-body:
    description: GET operations must not have a request body.
    severity: error
    given: $.paths[*].get
    then:
      field: requestBody
      function: falsy

  delete-no-request-body:
    description: DELETE operations should not have a request body.
    severity: warn
    given: $.paths[*].delete
    then:
      field: requestBody
      function: falsy

  # GENERAL QUALITY
  no-empty-descriptions:
    description: Descriptions must not be empty.
    severity: warn
    given: $..description
    then:
      function: truthy