Microsoft Edge · API Governance Rules

Microsoft Edge API Rules

Spectral linting rules defining API design standards and conventions for Microsoft Edge.

27 Rules error 15 warn 12
View Rules File View on GitHub

Rule Categories

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

Rules

error
info-title-prefix
Info title must start with "Microsoft Edge"
$.info.title
error
info-description-required
Info description is required
$.info
warn
info-description-min-length
Info description should be at least 50 characters
$.info.description
error
info-version-required
Info version is required
$.info
warn
info-contact-required
Info contact is required
$.info
error
openapi-version
OpenAPI version should be 3.0.x
$.openapi
error
servers-defined
At least one server must be defined
$
warn
servers-description
Each server should have a description
$.servers[*]
warn
paths-kebab-case
Path segments should use kebab-case
$.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]
warn
operation-summary-prefix
Operation summary should start with "Microsoft Edge"
$.paths[*][get,post,put,patch,delete].summary
error
operation-description-required
Every operation must have a description
$.paths[*][get,post,put,patch,delete]
error
operation-operationid-required
Every operation must have an operationId
$.paths[*][get,post,put,patch,delete]
warn
operation-operationid-camel-case
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
tags-title-case
Tags should use Title Case
$.paths[*][get,post,put,patch,delete].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[*]
error
response-success-required
Every operation must have a success response (2xx)
$.paths[*][get,post,put,patch,delete].responses
error
response-description-required
Every response must have a description
$.paths[*][get,post,put,patch,delete].responses[*]
warn
schema-description-required
Top-level schemas should have descriptions
$.components.schemas[*]
warn
schema-type-required
Schemas should have a type defined
$.components.schemas[*]
warn
security-schemes-defined
Security schemes should be defined when security is used
$.components
error
get-no-request-body
GET operations should not have a request body
$.paths[*].get
warn
delete-no-request-body
DELETE operations should not have a request body
$.paths[*].delete
error
no-empty-descriptions
Descriptions should not be empty strings
$..description

Spectral Ruleset

Raw ↑
rules:
  # INFO / METADATA
  info-title-prefix:
    description: Info title must start with "Microsoft Edge"
    severity: error
    given: $.info.title
    then:
      function: pattern
      functionOptions:
        match: ^Microsoft Edge
  info-description-required:
    description: Info description is required
    severity: error
    given: $.info
    then:
      field: description
      function: truthy
  info-description-min-length:
    description: Info description should be at least 50 characters
    severity: warn
    given: $.info.description
    then:
      function: length
      functionOptions:
        min: 50
  info-version-required:
    description: Info version is required
    severity: error
    given: $.info
    then:
      field: version
      function: truthy
  info-contact-required:
    description: Info contact is required
    severity: warn
    given: $.info
    then:
      field: contact
      function: truthy

  # OPENAPI VERSION
  openapi-version:
    description: OpenAPI version should be 3.0.x
    severity: error
    given: $.openapi
    then:
      function: pattern
      functionOptions:
        match: ^3\.0\.\d+$

  # SERVERS
  servers-defined:
    description: At least one server must be defined
    severity: error
    given: $
    then:
      field: servers
      function: truthy
  servers-description:
    description: Each server should 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
    severity: warn
    given: $.paths
    then:
      field: '@key'
      function: pattern
      functionOptions:
        match: ^(/[a-z0-9\-\{\}\.]+)+$
  paths-no-trailing-slash:
    description: Paths must not have trailing slashes
    severity: error
    given: $.paths
    then:
      field: '@key'
      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-summary-prefix:
    description: Operation summary should start with "Microsoft Edge"
    severity: warn
    given: $.paths[*][get,post,put,patch,delete].summary
    then:
      function: pattern
      functionOptions:
        match: ^Microsoft Edge
  operation-description-required:
    description: Every operation must have a description
    severity: error
    given: $.paths[*][get,post,put,patch,delete]
    then:
      field: description
      function: truthy
  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-camel-case:
    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
  tags-title-case:
    description: Tags should use Title Case
    severity: warn
    given: $.paths[*][get,post,put,patch,delete].tags[*]
    then:
      function: pattern
      functionOptions:
        match: ^[A-Z]

  # 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

  # RESPONSES
  response-success-required:
    description: Every operation must have a success response (2xx)
    severity: error
    given: $.paths[*][get,post,put,patch,delete].responses
    then:
      function: schema
      functionOptions:
        schema:
          anyOf:
            - required: ['200']
            - required: ['201']
            - required: ['202']
            - required: ['204']
  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

  # SCHEMAS
  schema-description-required:
    description: Top-level schemas should have descriptions
    severity: warn
    given: $.components.schemas[*]
    then:
      field: description
      function: truthy
  schema-type-required:
    description: Schemas should have a type defined
    severity: warn
    given: $.components.schemas[*]
    then:
      field: type
      function: truthy

  # SECURITY
  security-schemes-defined:
    description: Security schemes should be defined when security is used
    severity: warn
    given: $.components
    then:
      field: securitySchemes
      function: truthy

  # HTTP METHOD CONVENTIONS
  get-no-request-body:
    description: GET operations should 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 should not be empty strings
    severity: error
    given: $..description
    then:
      function: truthy