---
functions: 
  - havePlans
  - haveDocumentation
  - haveStatus
  - haveTermsOfService
  - havePrivacyPolicy
  - haveRateLimits
  - havePagination
  - haveAuthentication
  - haveGettingStarted
rules:
  apis-json-specification-version-error:
    description: Specification Version ~ docs.html
    message: There MUST BE a specification version.
    tags:
      - Change
    severity: error
    given: $
    then:
      field: specificationVersion
      function: truthy
  apis-json-specification-version-info:
    description: Specification Version ~ docs.html
    message: There is a specification version.
    tags:
      - Change    
    severity: info
    given: $
    then:
      field: specificationVersion
      function: falsy
  apis-json-specification-aid-warn:
    description: Unique AID ~ docs.html
    message: There COULD BE a unique aid.
    tags:
      - Reliability
      - Reuse 
      - Discovery     
    severity: warn
    given: $
    then:
      field: aid
      function: truthy
  apis-json-specification-aid-info:
    description: Unique AID ~ docs.html
    message: There is a unique aid.
    tags:
      - Reliability
      - Reuse 
      - Discovery      
    severity: info
    given: $
    then:
      field: aid
      function: falsy
  apis-json-name-error:
    description: Name ~ docs.html
    message: This resource MUST HAVE a name.
    tags:
      - Discovery
      - Metadata       
    given: $
    severity: info
    then:
      field: name
      function: truthy
  apis-json-name-info:
    description: Name ~ docs.html
    message: This resource has a name.
    tags:
      - Discovery
      - Metadata      
    given: $
    severity: info
    then:
      field: name
      function: falsy
  apis-json-specification-type-error:
    description: Resource Type ~ docs.html
    message: This MUST HAVE a type.
    tags:
      - Metadata      
    severity: error
    given: $
    then:
      - field: type
        function: truthy
  apis-json-specification-type-info:
    description: Resource Type ~ docs.html
    message: This has a type.
    tags:
      - Metadata      
    severity: info
    given: $
    then:
      - field: type
        function: falsy
  apis-json-specification-type-value-error:
    description: Resource Type Value ~ docs.html
    message: This MUST BE of type resource.
    tags:
      - Metadata      
    severity: error
    given: $
    then:
      function: pattern
      functionOptions:
        match: \b(resource|Resource)\b
  apis-json-specification-type-value-info:
    description: Resource Type Value ~ docs.html
    message: This is of type resource.
    tags:
      - Metadata      
    severity: info
    given: $
    then:
      function: pattern
      functionOptions:
        notMatch: \b(resource|Resource)\b
  apis-json-description-error:
    description: Resource Description ~ docs.html
    message: There MUST BE a description.
    tags:
      - Metadata  
      - Discovery    
    given: $
    severity: error
    then:
      field: description
      function: truthy
  apis-json-description-info:
    description: Resource Description ~ docs.html
    message: There is a description.
    tags:
      - Metadata  
      - Discovery     
    given: $
    severity: info
    then:
      field: description
      function: falsy
  apis-json-image-error:
    description: Image ~ docs.html
    message: There COULD BE an image.
    tags:
      - Metadata  
      - Discovery     
    given: $
    severity: warn
    then:
      field: image
      function: truthy
  apis-json-image-info:
    description: Image ~ docs.html
    message: There is an image.
    tags:
      - Metadata  
      - Discovery     
    given: $
    severity: info
    then:
      field: image
      function: falsy
  apis-json-created-error:
    description: Created Date ~ docs.html
    message: There MUST BE a created date.
    tags:
      - Metadata  
      - Change     
    given: $
    severity: error
    then:
      field: created
      function: truthy
  apis-json-created-info:
    description: Created Date ~ docs.html
    message: There is a created date.
    tags:
      - Metadata  
      - Change      
    given: $
    severity: info
    then:
      field: created
      function: falsy
  apis-json-modified-error:
    description: Modified Date ~ docs.html
    message: There MUST BE a modified date.
    tags:
      - Metadata  
      - Change      
    given: $
    severity: error
    then:
      field: modified
      function: truthy
  apis-json-modified-info:
    description: Modified Date ~ docs.html
    message: There is a modified date.
    tags:
      - Metadata  
      - Change      
    given: $
    severity: info
    then:
      field: modified
      function: falsy
  apis-json-maintainers-error:
    description: Maintainer ~ docs.html
    message: There MUST BE a maintainer.
    tags:
      - Metadata  
      - Support      
    given: $
    severity: error
    then:
      field: maintainers
      function: truthy
  apis-json-maintainers-info:
    description: Maintainer ~ docs.html
    message: There is a maintainer.
    tags:
      - Metadata  
      - Support     
    given: $
    severity: info
    then:
      field: maintainers
      function: falsy
  apis-json-maintainers-fn-error:
    description: Maintainer FN ~ docs.html
    message: There MUST BE a FN property for maintainers.
    tags:
      - Metadata  
      - Support     
    given: $.maintainers.*
    severity: error
    then:
      field: FN
      function: truthy
  apis-json-maintainers-fn-info:
    description: Maintainer FN ~ docs.html
    message: There is a FN property for maintainers.
    tags:
      - Metadata  
      - Support     
    given: $.maintainers.*
    severity: info
    then:
      field: FN
      function: falsy
  apis-json-maintainers-email-error:
    description: Maintainer Email ~ docs.html
    message: There MUST BE a email property for maintainers.
    tags:
      - Metadata  
      - Support     
    given: $.maintainers.*
    severity: error
    then:
      field: email
      function: truthy
  apis-json-maintainers-email-info:
    description: Maintainer Email ~ docs.html
    message: There is a email property for maintainers.
    tags:
      - Metadata  
      - Support     
    given: $.maintainers.*
    severity: info
    then:
      field: email
      function: falsy
  apis-json-tags-error:
    description: Tags ~ docs.html
    message: There MUST BE tags.
    tags:
      - Metadata  
      - Discovery  
    given: $
    severity: error
    then:
      field: tags
      function: truthy
  apis-json-tags-info:
    description: Tags ~ docs.html
    message: There are tags.
    tags:
      - Metadata  
      - Discovery      
    given: $
    severity: info
    then:
      field: tags
      function: falsy
  apis-json-tags-upper-case-error:
    description: Tags Casing ~ docs.html
    message: First letter of each word in tags need to be upper case.
    tags:
      - Metadata  
      - Discovery      
    severity: error
    given: $.tags.*
    then:
      function: pattern
      functionOptions:
        match: "[A-Z]\\w*"
  apis-json-tags-upper-case-info:
    description: Tags CAsing ~ docs.html
    message: First letter of each word in tags are upper case.
    tags:
      - Metadata  
      - Discovery      
    severity: info
    given: $.tags.*
    then:
      function: pattern
      functionOptions:
        notMatch: "[A-Z]\\w*"
  apis-json-url-error:
    description: URL ~ docs.html
    message: There MUST BE a URL.
    tags:
      - Metadata  
      - Discovery      
    given: $
    severity: error
    then:
      field: url
      function: truthy
  apis-json-url-info:
    description: URL ~ docs.html
    message: There is a URL.
    tags:
      - Metadata  
      - Discovery     
    given: $
    severity: info
    then:
      field: url
      function: falsy
  apis-json-apis-aid-error:
    description: API AID ~ docs.html
    message: APIs SHOULD HAVE a unique aid property.
    tags:
      - Reliability
      - Reuse 
      - Discovery    
    given: $.apis.*
    severity: warn
    then:
      field: aid
      function: truthy
  apis-json-apis-aid-info:
    description: API AID ~ docs.html
    message: API have a unique aid property.
    tags:
      - Reliability
      - Reuse 
      - Discovery 
    given: $.apis.*
    severity: info
    then:
      field: aid
      function: falsy


  apis-json-apis-description-info:
    description: API Description ~ docs.html
    message: Has a Description
    tags:
      - Discovery
      - Metadata 
    given: $.apis.*
    severity: info
    then:
      field: description
      function: falsy
  apis-json-apis-base-url-error:
    description: API Description. ~ docs.html
    message: APIs MUST Have a Base URL
    tags:
      - Reliability
      - Metadata     
    given: $.apis.*
    severity: error
    then:
      field: baseURL
      function: truthy
  apis-json-apis-base-url-info:
    description: Base URL ~ docs.html
    message: APIs Has a Base URL
    tags:
      - Reliability
      - Metadata      
    given: $.apis.*
    severity: info
    then:
      field: baseURL
      function: falsy
  apis-json-apis-human-url-error:
    description: Human URL ~ docs.html
    message: APIs MUST Have a Human URL
    tags:
      - Onboarding
      - Support
      - Metadata     
    given: $.apis.*
    severity: error
    then:
      field: humanURL
      function: truthy      
  apis-json-apis-human-url-info:
    description: Human URL ~ docs.html
    message: Has a Human URL
    tags:
      - Onboarding
      - Support
      - Metadata       
    given: $.apis.*
    severity: info
    then:
      field: humanURL
      function: falsy
  apis-json-apis-image-error:
    description: API Image ~ docs.html
    message: Has an Image
    tags:
      - Discovery
      - Metadata       
    given: $.apis.*
    severity: info
    then:
      field: image
      function: falsy
  apis-json-apis-image-info:
    description: API Image ~ docs.html
    message: Has an Image
    tags:
      - Discovery
      - Metadata       
    given: $.apis.*
    severity: info
    then:
      field: image
      function: falsy
  apis-json-apis-error:
    description: APIs ~ docs.html
    message: MUST Have APIs
    tags:
      - Automation    
    given: $
    severity: error
    then:
      field: apis
      function: truthy
  apis-json-apis-info:
    description: APIs ~ docs.html
    message: Has APIs
    tags:
      - Automation    
    given: $
    severity: info
    then:
      field: apis
      function: falsy    
  apis-json-apis-name-error:
    description: API Name ~ docs.html
    message: APIs MUST Have a Name
    tags:
      - Metadata  
      - Discovery    
    given: $.apis.*
    severity: error
    then:
      field: name
      function: truthy        
  apis-json-apis-name-info:
    description: API Name ~ docs.html
    message: Has a Name
    tags:
      - Metadata  
      - Discovery     
    given: $.apis.*
    severity: info
    then:
      field: name
      function: falsy
  apis-json-apis-tags-error:
    description: Tags ~ docs.html
    message: API MUST Have a Tags Object
    tags:
      - Metadata  
      - Discovery     
    given: $.apis.*
    severity: info
    then:
      field: tags
      function: truthy
  apis-json-apis-tags-info:
    description: Tags ~ docs.html
    message: API Have a Tags Object
    tags:
      - Metadata  
      - Discovery     
    given: $.apis.*
    severity: info
    then:
      field: tags
      function: falsy
  apis-json-apis-tags-upper-case-error:
    description: Tags Casing ~ docs.html
    message: API Tags MUST Be Upper Case
    tags:
      - Metadata  
      - Discovery     
    severity: error
    given: $.apis.*.tags.*
    then:
      function: pattern
      functionOptions:
        match: "[A-Z]\\w*"
  apis-json-apis-tags-upper-case-info:
    description: Tags Casing ~ docs.html
    message: API Tags are Upper Case
    tags:
      - Metadata  
      - Discovery     
    severity: info
    given: $.apis.*.tags.*
    then:
      function: pattern
      functionOptions:
        notMatch: "[A-Z]\\w*"
  apis-json-apis-properties-error:
    description: API Properties ~ docs.html
    message: Capabilities MUST HAVE properties.
    tags:
      - Metadata     
    severity: error
    given: $.apis.*
    then:
      field: properties
      function: truthy
  apis-json-apis-properties-info:
    description: API Properties ~ docs.html
    message: Resource has properties.
    tags:
      - Metadata        
    severity: info
    given: $.apis.*
    then:
      field: properties
      function: falsy
  apis-json-apis-properties-type-error:
    description: API Property Type ~ docs.html
    message: Capabilities MUST HAVE properties type.
    tags:
      - Metadata        
    severity: error
    given: $.apis.*.properties.*
    then:
      field: type
      function: truthy
  apis-json-apis-properties-type-info:
    description: API Property Type ~ docs.html
    message: Resource has property type.
    tags:
      - Metadata        
    severity: info
    given: $.apis.*.properties.*
    then:
      field: type
      function: falsy
  apis-json-apis-properties-type-value-error:
    description: Resource Type Value ~ docs.html
    message: This MUST BE of type OpenAPI.
    tags:
      - Metadata        
    severity: error
    given: $.apis.*.properties.*
    then:
      field: type
      function: pattern
      functionOptions:
        match: \b(OpenAPI)\b
  apis-json-apis-properties-type-value-info:
    description: Resource Type Value ~ docs.html
    message: This is of the type OpenAPI.
    tags:
      - Metadata        
    severity: info
    given: $.apis.*.properties.*
    then:
      field: type
      function: pattern
      functionOptions:
        notMatch: \b(OpenAPI)\b
  apis-json-apis-properties-data-error:
    description: API Property Data ~ docs.html
    message: Capabilities MUST HAVE properties data.
    tags:
      - Metadata    
      - Machine-Readable    
    severity: error
    given: $.apis.*.properties.*
    then:
      field: data
      function: truthy
  apis-json-apis-properties-data-info:
    description: API Property Type ~ docs.html
    message: Resource has property type.
    tags:
      - Metadata    
      - Machine-Readable     
    severity: info
    given: $.apis.*.properties.*
    then:
      field: data
      function: falsy  

  ## DOCUMENTATION
  apis-json-common-documentation-info:
    description: Common Documentation ~ docs.html
    message: Has API Documentation
    tags: 
      - Onboarding       
    severity: info
    given: $.common.*
    then:
      - field: type
        function: pattern
        functionOptions:
          notMatch: \b(Documentation)\b                        

  apis-json-common-documentation-error:
    description: Have Documentation ~ docs.html
    message: There COULD be documentation.
    tags: 
      - Onboarding     
    severity: hint
    given: $.common
    then:
      function: haveDocumentation                 

  ## PLANS
  apis-json-common-plans-info:
    description: Common Plans ~ docs.html
    message: Has API Plans
    tags: 
      - Business     
    severity: info
    given: $.common.*
    then:
      - field: type
        function: pattern
        functionOptions:
          notMatch: \b(Plans)\b      

  apis-json-common-plans-error:
    description: Have Plans ~ docs.html
    message: There COULD be plans & pricing.
    tags: 
      - Business         
    severity: hint
    given: $.common
    then:
      function: havePlans

  ## STATUS
  apis-json-common-status-info:
    description: Common Status ~ docs.html
    message: Has API Status
    tags: 
      - Reliability         
    severity: info
    given: $.common.*
    then:
      - field: type
        function: pattern
        functionOptions:
          notMatch: \b(Status)\b      

  apis-json-common-status-error:
    description: Have Status ~ docs.html
    message: There COULD be a status page.
    tags: 
      - Reliability     
    severity: hint
    given: $.common
    then:
      function: haveStatus

  ## TERMS OF SERVICE
  apis-json-common-terms-of-service-info:
    description: Common Terms of Service ~ docs.html
    message: Has API Terms of Service
    tags: 
      - Legal     
    severity: info
    given: $.common.*
    then:
      - field: type
        function: pattern
        functionOptions:
          notMatch: \b(TermsOfService)\b      

  apis-json-common-terms-of-service-error:
    description: Have Terms of Service ~ docs.html
    message: There COULD be a terms of service.
    tags: 
      - Legal     
    severity: hint
    given: $.common
    then:
      function: haveTermsOfService

  ## PRIVACY POLICY
  apis-json-common-privacy-policy-info:
    description: Common Privacy Policy ~ docs.html
    message: Has API Privacy Policy
    tags: 
      - Legal     
    severity: info
    given: $.common.*
    then:
      - field: type
        function: pattern
        functionOptions:
          notMatch: \b(PrivacyPolicy)\b      

  apis-json-common-privacy-policy-error:
    description: Have Privacy Policy ~ docs.html
    message: There COULD be a privacy policy.
    tags: 
      - Legal     
    severity: hint
    given: $.common
    then:
      function: havePrivacyPolicy

  ## RATE LIMITS
  apis-json-common-rate-limits-info:
    description: Common Rate Limits ~ docs.html
    message: Has API Rate Limits
    tags: 
      - Business
      - Usage     
    severity: info
    given: $.common.*
    then:
      - field: type
        function: pattern
        functionOptions:
          notMatch: \b(RateLimits)\b      

  apis-json-common-rate-limits-error:
    description: Have Rate Limits ~ docs.html
    message: There COULD be rate limits.
    tags: 
      - Business
      - Usage     
    severity: hint
    given: $.common
    then:
      function: haveRateLimits     


  ## PAGINATION
  apis-json-common-pagination-info:
    description: Common Pagination ~ docs.html
    message: Has API Pagination
    tags: 
      - Performance
      - Quality     
    severity: info
    given: $.common.*
    then:
      - field: type
        function: pattern
        functionOptions:
          notMatch: \b(Pagination)\b      

  apis-json-common-pagination-error:
    description: Have Pagination ~ docs.html
    message: There COULD be pagination.
    severity: hint
    tags: 
      - Performance
      - Quality      
    given: $.common
    then:
      function: havePagination
      
  ## AUTHENTICATION
  apis-json-common-authentication-info:
    description: Common Authentication ~ docs.html
    message: Has API Authentication
    tags: 
      - Security     
    severity: info
    given: $.common.*
    then:
      - field: type
        function: pattern
        functionOptions:
          notMatch: \b(Authentication)\b      

  apis-json-common-authentication-error:
    description: Have Authentication ~ docs.html
    message: There could be authentication.
    tags: 
      - Security      
    severity: hint
    given: $.common
    then:
      function: haveAuthentication

  ## GETTING STARTED
  apis-json-common-getting-started-info:
    description: Common Getting Started ~ docs.html
    message: Has API Getting Started
    tags: 
      - Onboarding      
    severity: info
    given: $.common.*
    then:
      - field: type
        function: pattern
        functionOptions:
          notMatch: \b(GettingStarted)\b      

  apis-json-common-getting-started-error:
    description: Have Getting Started ~ docs.html
    message: There COULD be a getting started.
    tags: 
      - Onboarding      
    severity: hint
    given: $.common
    then:
      function: haveGettingStarted    
