MongoDB · API Governance Rules

MongoDB — openapi rules

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

10 Rules error 10
Published by MongoDB Served by the provider at https://github.com/mongodb/openapi/blob/e579b1476f09280be945ffc1872c92f5a7e84c61/tools/spectral/.spectral.yaml; the copy below was fetched from there.
View Rules File View on GitHub

Rule Categories

accept soa x xgen

Rules

error
accept-header-upcoming-version-limit
Ensure that each operation has at most one upcoming API Accept header.
$.paths[*][*]
error
xgen-schema-name-pascal-case
OpenAPI Schema names should use PascalCase. PascalCase ensures consistency with OpenAPI generated code.
$.components.schemas[*]~
error
xgen-docs-tags-alphabetical
Many documentation tools show tags in the order they are defined, so defining them not in alphabetical order can look funny to API consumers.
$
error
xgen-docs-tags
Tags help group logic into conceptual groups instead of making end-users dig through URLs or lists of operation names.
$
error
xgen-docs-operation-tags
Once tags are defined they should be references in the operation, otherwise they will not be doing anything.
#OperationObject
error
xgen-docs-operationId-valid-in-url
Most documentation tools use the operationId to produce URLs, so the characters used must be safe and legal when used in the URL.
#OperationObject
error
xgen-docs-operationId-camel-case
operationId should be camelCased.
$.paths[*]..operationId
error
x-xgen-hidden-env-format
Ensure x-xgen-hidden-env extension has the correct format. https://go/openapi-hidden-extension
$..x-xgen-hidden-env
error
soa-migration-extension
Ensure the x-xgen-soa-migration extension is valid.
$.paths[*][*].x-xgen-soa-migration
error
xgen-security-override
Security must not be set at resource or method level because it is set globally. Use @Unauthenticated annotation to set no security. https://go/openapi-unauthenticated-annotation
#OperationObject.security

Spectral Ruleset

Raw ↑
# harvested from https://github.com/mongodb/openapi/blob/e579b1476f09280be945ffc1872c92f5a7e84c61/tools/spectral/.spectral.yaml on 2026-10-09 — a Spectral ruleset published in the provider's own GitHub repository (mongodb/openapi); found by GitHub code search, fetched verbatim
x-method: harvested
x-stamped: 2026-10-09
x-source-url: https://github.com/mongodb/openapi/blob/e579b1476f09280be945ffc1872c92f5a7e84c61/tools/spectral/.spectral.yaml
# https://meta.stoplight.io/docs/spectral/cb95cf0d26b83-core-functions
extends:
  - spectral:oas

aliases:
  PathItem:
    - "$.paths[*]"
  OperationObject:
    - "#PathItem[get,put,post,delete,options,head,patch,trace]"
  DescribableObjects:
    - "$.info"
    - "$.tags[*]"
    - "#OperationObject"
    - "#PathItem.parameters[?(@ && @.in)]"
    - "#OperationObject.parameters[?(@ && @.in)]"
    - "$.components.schemas[*]..properties[?(@ && @.type)]"

functions:
  - acceptHeaderUpcomingVersionLimit

rules:
  accept-header-upcoming-version-limit:
    description: Ensure that each operation has at most one upcoming API Accept header.
    message: "An operation must not have more than one upcoming API Accept header (format: application/vnd.atlas.YYYY-MM-DD.upcoming+format)."
    severity: error
    given: $.paths[*][*]
    then:
      function: "acceptHeaderUpcomingVersionLimit"
      
  xgen-schema-name-pascal-case:
    description: OpenAPI Schema names should use PascalCase. PascalCase ensures consistency with OpenAPI generated code.
    message: "`{{property}}` name must follow PascalCase. Please verify if you have provided valid @Schema(name='') annotation"
    severity: error
    given: "$.components.schemas[*]~"
    then:
      function: pattern # casing?
      functionOptions:
        match: "^[A-Z].*" # type: pascal ?

  xgen-docs-tags-alphabetical:
    message: "Tags should be defined in alphabetical order."
    description: "Many documentation tools show tags in the order they are defined, so defining them not in alphabetical order can look funny to API consumers."
    severity: error
    given: "$"
    then:
      field: "tags"
      function: alphabetical
      functionOptions:
        keyedBy: "name"

  xgen-docs-tags:
    message: "{{error}}."
    description: "Tags help group logic into conceptual groups instead of making end-users dig through URLs or lists of operation names."
    severity: error
    given: "$"
    then:
      field: "tags"
      function: schema
      functionOptions:
        schema:
          type: "array"
          minItems: 1

  xgen-docs-operation-tags:
    message: "Operation should have non-empty `tags` array."
    description:
     "Once tags are defined they should be references in the operation, otherwise they will not be doing anything."
    severity: error
    given: "#OperationObject"
    then:
      field: "tags"
      function: schema
      functionOptions:
        schema:
          type: "array"
          minItems: 1

  xgen-docs-operationId-valid-in-url:
    message: "operationId must only contain URL friendly characters."
    description: "Most documentation tools use the operationId to produce URLs, so the characters used must be safe and legal when used in the URL."
    severity: error
    given: "#OperationObject"
    then:
      field: "operationId"
      function: pattern
      functionOptions:
        match: "^[A-Za-z0-9-._~:/?#\\[\\]@!\\$&'()*+,;=]*$"

  xgen-docs-operationId-camel-case:
    description: operationId should be camelCased.
    given: "$.paths[*]..operationId"
    severity: error
    message: "Operation ID should be camelCase: {{value}}."
    then:
      function: casing
      functionOptions:
        type: camel

  x-xgen-hidden-env-format:
    description: "Ensure x-xgen-hidden-env extension has the correct format. https://go/openapi-hidden-extension"
    severity: error
    given: "$..x-xgen-hidden-env"                    # Match anywhere in the document
    then:
      - field: envs
        function: truthy
      - field: envs
        function: pattern
        functionOptions:
          match: "^(dev|qa|stage|prod)(,(dev|qa|stage|prod))*$"
  
  soa-migration-extension:
    description: "Ensure the x-xgen-soa-migration extension is valid."
    message: "The x-xgen-soa-migration extension must include 'additionalServices', 'targetService', 'allowDocsDiff', and 'docsSource'."
    formats: ["oas3"]
    given: "$.paths[*][*].x-xgen-soa-migration"
    severity: error
    then:
      - field: targetService
        function: truthy
        message: "'targetService' must be provided."
      - field: allowDocsDiff
        function: pattern
        functionOptions:
          match: "^(true|false)$"
        message: "'allowDocsDiff' must be true or false."
      - field: docsSource
        function: truthy
        message: "'docsSource' must be provided."
      - field: additionalServices
        function: truthy
        message: "'additionalServices' must be provided."
      - field: additionalServices
        function: pattern
        functionOptions:
          match: "^mms(,[a-zA-Z0-9_-]+)*$"
        message: "'additionalServices' must start with 'mms' and can include additional services in a comma-separated format."

  xgen-security-override:
    description: "Security must not be set at resource or method level because it is set globally. Use @Unauthenticated annotation to set no security. https://go/openapi-unauthenticated-annotation"
    severity: error
    given: "#OperationObject.security"
    then:
      function: schema
      functionOptions:
        schema:
          type: array
          items:
            type: object
          minItems: 0
          maxItems: 0

overrides:
  - files: # load sample data has an issue with different path param names for different VERBS
      - "*.yaml#/paths/~1api~1atlas~1v1.0~1groups~1%7BgroupId%7D~1sampleDatasetLoad~1%7BsampleDatasetId%7D"
      - "*.yaml#/paths/~1api~1atlas~1v1.0~1groups~1%7BgroupId%7D~1sampleDatasetLoad~1%7Bname%7D"
      - "*.yaml#/paths/~1api~1atlas~1v2~1groups~1%7BgroupId%7D~1sampleDatasetLoad~1%7Bname%7D"
      - "*.yaml#/paths/~1api~1atlas~1v2~1groups~1%7BgroupId%7D~1sampleDatasetLoad~1%7BsampleDatasetId%7D"
    rules:
      path-params: "off"
  - files:
      - "*.yaml#/components/schemas/raw"
      - "*.yaml#/components/schemas/charFilterhtmlStrip"
      - "*.yaml#/components/schemas/charFiltericuNormalize"
      - "*.yaml#/components/schemas/charFiltermapping"
      - "*.yaml#/components/schemas/charFilterpersian"
      - "*.yaml#/components/schemas/tokenizernGram"
      - "*.yaml#/components/schemas/tokenizeredgeGram"
      - "*.yaml#/components/schemas/tokenizerkeyword"
      - "*.yaml#/components/schemas/tokenizerregexCaptureGroup"
      - "*.yaml#/components/schemas/tokenizerregexSplit"
      - "*.yaml#/components/schemas/tokenizerstandard"
      - "*.yaml#/components/schemas/tokenizeruaxUrlEmail"
      - "*.yaml#/components/schemas/tokenizerwhitespace"
      - "*.yaml#/components/schemas/tokenFilterasciiFolding"
      - "*.yaml#/components/schemas/tokenFilterdaitchMokotoffSoundex"
      - "*.yaml#/components/schemas/tokenFilteredgeGram"
      - "*.yaml#/components/schemas/tokenFiltericuFolding"
      - "*.yaml#/components/schemas/tokenFiltericuNormalizer"
      - "*.yaml#/components/schemas/tokenFilterlength"
      - "*.yaml#/components/schemas/tokenFilterlowercase"
      - "*.yaml#/components/schemas/tokenFilternGram"
      - "*.yaml#/components/schemas/tokenFilterregex"
      - "*.yaml#/components/schemas/tokenFilterreverse"
      - "*.yaml#/components/schemas/tokenFiltershingle"
      - "*.yaml#/components/schemas/tokenFiltersnowballStemming"
      - "*.yaml#/components/schemas/tokenFilterstopword"
      - "*.yaml#/components/schemas/tokenFiltertrim"
    rules:
        xgen-schema-name-pascal-case: "off"

Work with this as data

Every ruleset here is available over the APIs.io API and to AI agents over MCP.

MCP server

One button, every client — Claude, Cursor, VS Code and the rest.

https://apis.io/mcp

Tools for spectral rules

4 MCP tools reach this
  • find_rulesBrowse and filter every ruleset in the catalog.
  • apis_io_searchSTART HERE — APIs, providers and tags for one query, each with its total.
  • resolveTurn a domain, URL or GitHub org into the provider it belongs to.
  • find_cohortsEvery scored population of providers in the catalog.
All 92 tools →

Call it yourself

curl for this page
This ruleset
curl "https://apis.io/api/v1/rules/mongodb-openapi-spectral-rules"
All spectral rules
curl "https://apis.io/api/v1/rules?limit=25"

Discovery needs no key. Ratings and market analysis are Pro.

Get an API key

Free tier, no form to fill in. Signing in shares your email address with us — we store it to create your key and to recognise you if you sign in with another provider. See our Privacy Policy and Terms.

A second provider on the same verified email joins the account you already have.