Random User Generator · API Governance Rules

Random User Generator API Rules

Spectral linting rules defining API design standards and conventions for Random User Generator.

10 Rules error 6 warn 3 info 1
View Rules File View on GitHub

Rule Categories

randomuser

Rules

error
randomuser-operation-id-camelcase
Operation IDs MUST be camelCase (generateUsers, generateUsersVersioned).
$.paths[*][get,post,put,patch,delete].operationId
warn
randomuser-summary-title-case
Operation summaries MUST be in Title Case.
$.paths[*][get,post,put,patch,delete].summary
error
randomuser-operation-must-have-tag
Every operation MUST be tagged (Users for this API).
$.paths[*][get,post,put,patch,delete]
error
randomuser-results-bounded
The `results` query parameter MUST cap at 5000 to match the documented limit.
$.paths[*].get.parameters[?(@.name=='results')].schema
warn
randomuser-gender-enum
The `gender` query parameter MUST enumerate male/female.
$.paths[*].get.parameters[?(@.name=='gender')].schema
warn
randomuser-format-enum
The `format` query parameter MUST enumerate the documented serializers.
$.paths[*].get.parameters[?(@.name=='format')].schema.enum
error
randomuser-no-auth
Random User Generator is unauthenticated; do NOT define securitySchemes.
$.components.securitySchemes
error
randomuser-server-https
Servers MUST be HTTPS.
$.servers[*].url
error
randomuser-user-schema-present
Components MUST define a User schema (the canonical resource).
$.components.schemas
info
randomuser-microcks-extension
Each operation SHOULD carry an x-microcks-operation block so it can mock cleanly.
$.paths[*][get,post,put,patch,delete]

Spectral Ruleset

Raw ↑
extends: [["spectral:oas", all]]

documentationUrl: https://randomuser.me/documentation

rules:
  # The Random User Generator publishes one stable read operation; surface it
  # as such and keep operationIds, summaries, and tags consistent.

  randomuser-operation-id-camelcase:
    description: Operation IDs MUST be camelCase (generateUsers, generateUsersVersioned).
    severity: error
    given: $.paths[*][get,post,put,patch,delete].operationId
    then:
      function: pattern
      functionOptions:
        match: "^[a-z][a-zA-Z0-9]*$"

  randomuser-summary-title-case:
    description: Operation summaries MUST be in Title Case.
    severity: warn
    given: $.paths[*][get,post,put,patch,delete].summary
    then:
      function: pattern
      functionOptions:
        match: "^([A-Z][a-zA-Z0-9]*)( [A-Z][a-zA-Z0-9]*)*$"

  randomuser-operation-must-have-tag:
    description: Every operation MUST be tagged (Users for this API).
    severity: error
    given: $.paths[*][get,post,put,patch,delete]
    then:
      field: tags
      function: truthy

  randomuser-results-bounded:
    description: The `results` query parameter MUST cap at 5000 to match the documented limit.
    severity: error
    given: $.paths[*].get.parameters[?(@.name=='results')].schema
    then:
      - field: maximum
        function: truthy
      - field: maximum
        function: enumeration
        functionOptions:
          values: [5000]

  randomuser-gender-enum:
    description: The `gender` query parameter MUST enumerate male/female.
    severity: warn
    given: $.paths[*].get.parameters[?(@.name=='gender')].schema
    then:
      field: enum
      function: truthy

  randomuser-format-enum:
    description: The `format` query parameter MUST enumerate the documented serializers.
    severity: warn
    given: $.paths[*].get.parameters[?(@.name=='format')].schema.enum
    then:
      function: enumeration
      functionOptions:
        values: [json, pretty, csv, yaml, xml]

  randomuser-no-auth:
    description: Random User Generator is unauthenticated; do NOT define securitySchemes.
    severity: error
    given: $.components.securitySchemes
    then:
      function: falsy

  randomuser-server-https:
    description: Servers MUST be HTTPS.
    severity: error
    given: $.servers[*].url
    then:
      function: pattern
      functionOptions:
        match: "^https://"

  randomuser-user-schema-present:
    description: Components MUST define a User schema (the canonical resource).
    severity: error
    given: $.components.schemas
    then:
      field: User
      function: truthy

  randomuser-microcks-extension:
    description: Each operation SHOULD carry an x-microcks-operation block so it can mock cleanly.
    severity: info
    given: $.paths[*][get,post,put,patch,delete]
    then:
      field: x-microcks-operation
      function: truthy