---
rules:
  openapi-operation-security-definitions-error:
    description: >-
      Each API operation should have a security definition referencing the
      central security scheme express for an OpenAPI
    message: Operations MUST Have a Security Definition
    severity: error
    given: $.paths.*[get,post,patch,put,delete]
    then:
      field: security
      function: truthy
  openapi-operation-security-definitions-info:
    description: >-
      Each API operation should have a security definition referencing the
      central security scheme express for an OpenAPI
    message: Operations MUST Have a Security Definition
    severity: info
    given: $.paths.*[get,post,patch,put,delete]
    then:
      field: security
      function: falsy
  openapi-operations-description-error:
    description: >-
      Having a paragraph or two description of each API operation helps API
      consumers understand what is possible with each API request
    message: Operation MUST Have Description
    severity: error
    given: $.paths.*[get,post,patch,put,delete]
    then:
      - field: description
        function: truthy
  openapi-operations-description-info:
    description: >-
      Having a paragraph or two description of each API operation helps API
      consumers understand what is possible with each API request
    message: Operation Has Description
    severity: info
    given: $.paths.*[get,post,patch,put,delete]
    then:
      - field: description
        function: falsy
  openapi-operations-description-length-error:
    description: >-
      Having a length limitation for each description of each API operation
      helps apply constraints to how you describe your APIs, while helping drive
      consistency across APIs when it comes to search, documentation, and other
      ways an API is made available
    message: Operation Description MUST Be Less Than 250 Characters
    given: $.paths.*[get,post,patch,put,delete]
    then:
      - field: description
        function: length
        functionOptions:
          max: 250
  openapi-operations-operation-ids-camel-case-error:
    description: >-
      Operation identifiers provide a unique way to identify each individual
      API, and requiring them to have consistent casing reduces friction when
      generating SDKs and automating around APIs
    message: Operation Identifier MUST Be camelCase
    severity: error
    given: $.paths.*[get,post,patch,put,delete].operationId
    then:
      - function: pattern
        functionOptions:
          match: ^[a-z]+(?:[A-Z][a-z]+)*$
  openapi-operations-operation-ids-camel-case-info:
    description: >-
      Operation identifiers provide a unique way to identify each individual
      API, and requiring them to have consistent casing reduces friction when
      generating SDKs and automating around APIs
    message: Operation Identifier Is camelCase
    severity: info
    given: $.paths.*[get,post,patch,put,delete].operationId
    then:
      - function: pattern
        functionOptions:
          notMatch: ^[a-z]+(?:[A-Z][a-z]+)*$
  openapi-operations-operation-ids-error:
    description: >-
      Operation identifiers provide a unique way to identify each individual
      API, which then used for SDK generation and other automation
    message: Operation MUST Have Identifier
    severity: error
    given: $.paths.*[get,post,patch,put,delete]
    then:
      - field: operationId
        function: truthy
  openapi-operations-operation-ids-info:
    description: >-
      Operation identifiers provide a unique way to identify each individual
      API, which then used for SDK generation and other automation
    message: Operation Has Identifier
    severity: info
    given: $.paths.*[get,post,patch,put,delete]
    then:
      - field: operationId
        function: falsy
  openapi-operations-summary-error:
    description: >-
      Having short and intuitive summary for each API operation helps API
      consumers understand what is possible with each API request
    message: Operation MUST Have a Summary
    severity: error
    given: $.paths.*[get,post,patch,put,delete]
    then:
      - field: summary
        function: truthy
  openapi-operations-summary-info:
    description: >-
      Having short and intuitive summary for each API operation helps API
      consumers understand what is possible with each API request
    message: Operation Has a Summary
    severity: info
    given: $.paths.*[get,post,patch,put,delete]
    then:
      - field: summary
        function: falsy
  openapi-operations-summary-length-error:
    description: >-
      Apply length constraints to the operation summary helps keep them
      consistent for publishing in documentation
    message: Operation Summary MUST Be Less Than 50 Characters
    given: $.paths.*[get,post,patch,put,delete]
    then:
      - field: summary
        function: length
        functionOptions:
          max: 50
    type: style
  openapi-operations-summary-period-none-error:
    description: >-
      Operation summaries should not have a period, keeping the primary summary
      for each API as consistent as possible for publishing in documentation
    message: Operation MUST Not Have a Period.
    severity: error
    given: $.paths[*][*].summary
    then:
      function: pattern
      functionOptions:
        notMatch: \.$
  openapi-operations-summary-period-none-info:
    description: >-
      Operation summaries should not have a period, keeping the primary summary
      for each API as consistent as possible for publishing in documentation
    message: Operation Has a Period.
    severity: info
    given: $.paths[*][*].summary
    then:
      function: pattern
      functionOptions:
        match: \.$
  openapi-operations-tags-error:
    description: >-
      Having tags applied to each API operations helps organize and group APIs
      in portals, documentation, search, and other ways in which APIs are made
      available
    message: Operations MUST Have Tags
    severity: error
    given: $.paths.*[get,post,patch,put,delete]
    then:
      - field: tags
        function: truthy
  openapi-operations-tags-info:
    description: >-
      Having tags applied to each API operations helps organize and group APIs
      in portals, documentation, search, and other ways in which APIs are made
      available
    message: Operations Has Tags
    severity: info
    given: $.paths.*[get,post,patch,put,delete]
    then:
      - field: tags
        function: falsy
  openapi-operations-tags-one-error:
    description: >-
      Having tags applied to each API operations helps organize and group APIs
      in portals, documentation, search, and other ways in which APIs are made
      available
    message: MUST Be At Least One Operation Tag
    given: $.paths.*[get,post,patch,put,delete]
    severity: error
    then:
      field: tags
      function: length
      functionOptions:
        min: 1
  openapi-operations-tags-upper-case-error:
    description: >-
      Having the first letter of each word applied as a tag to API operations
      helps keep a consistent layout when published via search, documentation,
      and other ways APIs are made available
    message: Operation Tag Names MUST Have First Letter in Each Word Capitalized
    severity: error
    given: $.paths.*[get,post,patch,put,delete].tags.*
    then:
      function: pattern
      functionOptions:
        match: '[A-Z]\w*'
  openapi-operations-tags-upper-case-info:
    description: >-
      Having the first letter of each word applied as a tag to API operations
      helps keep a consistent layout when published via search, documentation,
      and other ways APIs are made available
    message: Operation Tag Names Have First Letter in Each Word Capitalized
    severity: info
    given: $.paths.*[get,post,patch,put,delete].tags.*
    then:
      function: pattern
      functionOptions:
        notMatch: '[A-Z]\w*'