Merge · API Governance Rules

Merge API Rules

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

41 Rules error 15 warn 19 info 7
View Rules File View on GitHub

Rule Categories

delete error examples get info no openapi operation pagination parameter paths query remote request response schema security servers

Rules

error
info-title-required
Info object must have a title.
$.info
warn
info-title-merge-prefix
Info title should start with "Merge".
$.info.title
error
info-description-required
Info object must have a description.
$.info
warn
info-description-min-length
Info description should be at least 50 characters.
$.info.description
error
info-version-required
Info object must have a version.
$.info
warn
info-contact-required
Info object should have contact information.
$.info
warn
openapi-version-3
OpenAPI version should be 3.x.
$
error
servers-defined
At least one server must be defined.
$
error
servers-https
Server URLs should use HTTPS.
$.servers[*].url
info
servers-merge-api-domain
Server URL should be on api.merge.dev.
$.servers[*].url
warn
paths-kebab-case
Path segments should use kebab-case.
$.paths
error
paths-no-trailing-slash
Paths must not have trailing slashes.
$.paths
info
paths-plural-resources
Resource paths should use plural nouns.
$.paths
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-summary-required
Every operation must have a summary.
$.paths[*][get,post,put,patch,delete]
warn
operation-summary-merge-prefix
Operation summaries should start with "Merge".
$.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-tags-required
Every operation must have at least one tag.
$.paths[*][get,post,put,patch,delete]
warn
parameter-description-required
Every parameter must have a description.
$.paths[*][*].parameters[*]
warn
parameter-snake-case
Parameter names should use snake_case.
$.paths[*][*].parameters[*].name
info
parameter-pagination-cursor
Merge APIs use cursor-based pagination with cursor parameter.
$.paths[*].get.parameters
warn
request-body-json
Request bodies should use application/json.
$.paths[*][post,put,patch].requestBody.content
error
response-success-required
Every operation must have a success response.
$.paths[*][get,post,put,patch,delete].responses
error
response-description-required
Every response must have a description.
$.paths[*][*].responses[*]
warn
schema-property-snake-case
Schema properties should use snake_case naming.
$.components.schemas[*].properties
warn
schema-type-defined
Schemas must define a type.
$.components.schemas[*]
info
schema-description
Top-level schemas should have descriptions.
$.components.schemas[*]
error
security-defined
Global security must be defined.
$
warn
security-bearer-auth
Merge APIs should use Bearer token authentication.
$.components.securitySchemes
warn
security-account-token-header
Merge APIs require X-Account-Token header.
$.components.securitySchemes
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
info
pagination-response-format
List endpoints should return paginated responses with next/previous/results.
$.paths[*].get.responses.200.content.application/json.schema
info
remote-was-deleted-field
Merge schemas should include remote_was_deleted field for soft delete tracking.
$.components.schemas[?(@.type=='object' && !@.title.match(/Paginated|Request|Error/))]
error
no-empty-descriptions
Descriptions must not be empty strings.
$..description
info
examples-encouraged
Schema properties should include example values.
$.components.schemas[*].properties[*]
warn
servers-expected-domain
Server URLs should be on the merge.dev domain.
$.servers[*].url
warn
query-params-casing
Query parameters should be snake_case (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
warn
error-schema-defined
A shared error schema (ErrorValidationProblem) should be defined for error payloads.
$.components.schemas

Spectral Ruleset

Raw ↑
# merge — 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: 27/27 servers on merge.dev
#   - path-params-casing: snake @ 100% (n=246)
#   - query-params-casing: snake @ 100% (n=2432)
#   - operationid-casing: snake @ 59% (n=621)
#   - schema-names-casing: pascal @ 99% (n=1662)
#   - schema-properties-casing: snake @ 95% (n=6024)
#   - security: neither global nor consistently per-op — schemes-defined only
#   - error-schema-defined: ErrorValidationProblem
#   - pagination params observed: ['cursor', 'limit', 'page', 'page_size']
#   - merge: kept 37 existing, added 4 measured, upgraded 0
#   - added: servers-expected-domain, query-params-casing, schema-names-casing, error-schema-defined
extends:
  - spectral:oas
rules:
  info-title-required:
    description: Info object must have a title.
    given: $.info
    severity: error
    then:
      field: title
      function: truthy
  info-title-merge-prefix:
    description: Info title should start with "Merge".
    given: $.info.title
    severity: warn
    then:
      function: pattern
      functionOptions:
        match: ^Merge
  info-description-required:
    description: Info object must have a description.
    given: $.info
    severity: error
    then:
      field: description
      function: truthy
  info-description-min-length:
    description: Info description should be at least 50 characters.
    given: $.info.description
    severity: warn
    then:
      function: length
      functionOptions:
        min: 50
  info-version-required:
    description: Info object must have a version.
    given: $.info
    severity: error
    then:
      field: version
      function: truthy
  info-contact-required:
    description: Info object should have contact information.
    given: $.info
    severity: warn
    then:
      field: contact
      function: truthy
  openapi-version-3:
    description: OpenAPI version should be 3.x.
    given: $
    severity: warn
    then:
      field: openapi
      function: pattern
      functionOptions:
        match: ^3\.
  servers-defined:
    description: At least one server must be defined.
    given: $
    severity: error
    then:
      field: servers
      function: truthy
  servers-https:
    description: Server URLs should use HTTPS.
    given: $.servers[*].url
    severity: error
    then:
      function: pattern
      functionOptions:
        match: ^https://
  servers-merge-api-domain:
    description: Server URL should be on api.merge.dev.
    given: $.servers[*].url
    severity: info
    then:
      function: pattern
      functionOptions:
        match: api\.merge\.dev
  paths-kebab-case:
    description: Path segments should use kebab-case.
    given: $.paths
    severity: warn
    then:
      field: '@key'
      function: pattern
      functionOptions:
        match: ^(\/[a-z0-9-{}]+)+$
  paths-no-trailing-slash:
    description: Paths must not have trailing slashes.
    given: $.paths
    severity: error
    then:
      field: '@key'
      function: pattern
      functionOptions:
        notMatch: \/$
  paths-plural-resources:
    description: Resource paths should use plural nouns.
    given: $.paths
    severity: info
    then:
      field: '@key'
      function: pattern
      functionOptions:
        notMatch: \/[a-z]+[^s{}]\/\{
  operation-operationid-required:
    description: Every operation must have an operationId.
    given: $.paths[*][get,post,put,patch,delete]
    severity: error
    then:
      field: operationId
      function: truthy
  operation-operationid-camel-case:
    description: operationId should use camelCase.
    given: $.paths[*][get,post,put,patch,delete].operationId
    severity: warn
    then:
      function: pattern
      functionOptions:
        match: ^[a-z][a-zA-Z0-9]*$
  operation-summary-required:
    description: Every operation must have a summary.
    given: $.paths[*][get,post,put,patch,delete]
    severity: error
    then:
      field: summary
      function: truthy
  operation-summary-merge-prefix:
    description: Operation summaries should start with "Merge".
    given: $.paths[*][get,post,put,patch,delete].summary
    severity: warn
    then:
      function: pattern
      functionOptions:
        match: ^Merge
  operation-description-required:
    description: Every operation must have a description.
    given: $.paths[*][get,post,put,patch,delete]
    severity: error
    then:
      field: description
      function: truthy
  operation-tags-required:
    description: Every operation must have at least one tag.
    given: $.paths[*][get,post,put,patch,delete]
    severity: error
    then:
      field: tags
      function: truthy
  parameter-description-required:
    description: Every parameter must have a description.
    given: $.paths[*][*].parameters[*]
    severity: warn
    then:
      field: description
      function: truthy
  parameter-snake-case:
    description: Parameter names should use snake_case.
    given: $.paths[*][*].parameters[*].name
    severity: warn
    then:
      function: pattern
      functionOptions:
        match: ^[a-z][a-z0-9_]*$
  parameter-pagination-cursor:
    description: Merge APIs use cursor-based pagination with cursor parameter.
    given: $.paths[*].get.parameters
    severity: info
    then:
      function: schema
      functionOptions:
        schema:
          type: array
          contains:
            type: object
            properties:
              name:
                const: cursor
  request-body-json:
    description: Request bodies should use application/json.
    given: $.paths[*][post,put,patch].requestBody.content
    severity: warn
    then:
      field: application/json
      function: truthy
  response-success-required:
    description: Every operation must have a success response.
    given: $.paths[*][get,post,put,patch,delete].responses
    severity: error
    then:
      function: schema
      functionOptions:
        schema:
          anyOf:
          - required:
            - '200'
          - required:
            - '201'
          - required:
            - '204'
  response-description-required:
    description: Every response must have a description.
    given: $.paths[*][*].responses[*]
    severity: error
    then:
      field: description
      function: truthy
  schema-property-snake-case:
    description: Schema properties should use snake_case naming.
    given: $.components.schemas[*].properties
    severity: warn
    then:
      field: '@key'
      function: pattern
      functionOptions:
        match: ^[a-z][a-z0-9_]*$
  schema-type-defined:
    description: Schemas must define a type.
    given: $.components.schemas[*]
    severity: warn
    then:
      field: type
      function: truthy
  schema-description:
    description: Top-level schemas should have descriptions.
    given: $.components.schemas[*]
    severity: info
    then:
      field: description
      function: truthy
  security-defined:
    description: Global security must be defined.
    given: $
    severity: error
    then:
      field: security
      function: truthy
  security-bearer-auth:
    description: Merge APIs should use Bearer token authentication.
    given: $.components.securitySchemes
    severity: warn
    then:
      field: bearerAuth
      function: truthy
  security-account-token-header:
    description: Merge APIs require X-Account-Token header.
    given: $.components.securitySchemes
    severity: warn
    then:
      field: accountToken
      function: truthy
  get-no-request-body:
    description: GET operations must not have a request body.
    given: $.paths[*].get
    severity: error
    then:
      field: requestBody
      function: falsy
  delete-no-request-body:
    description: DELETE operations should not have a request body.
    given: $.paths[*].delete
    severity: warn
    then:
      field: requestBody
      function: falsy
  pagination-response-format:
    description: List endpoints should return paginated responses with next/previous/results.
    given: $.paths[*].get.responses.200.content.application/json.schema
    severity: info
    then:
      function: schema
      functionOptions:
        schema:
          type: object
          properties:
            $ref:
              type: string
              pattern: Paginated
  remote-was-deleted-field:
    description: Merge schemas should include remote_was_deleted field for soft delete tracking.
    given: $.components.schemas[?(@.type=='object' && !@.title.match(/Paginated|Request|Error/))]
    severity: info
    then:
      field: properties.remote_was_deleted
      function: truthy
  no-empty-descriptions:
    description: Descriptions must not be empty strings.
    given: $..description
    severity: error
    then:
      function: truthy
  examples-encouraged:
    description: Schema properties should include example values.
    given: $.components.schemas[*].properties[*]
    severity: info
    then:
      field: example
      function: truthy
  servers-expected-domain:
    description: Server URLs should be on the merge.dev domain.
    severity: warn
    given: $.servers[*].url
    then:
      function: pattern
      functionOptions:
        match: merge\.dev
  query-params-casing:
    description: Query parameters should be snake_case (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: snake
  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]*$
  error-schema-defined:
    description: A shared error schema (ErrorValidationProblem) should be defined for error payloads.
    severity: warn
    given: $.components.schemas
    then:
      field: ErrorValidationProblem
      function: truthy