---
functions: 
  - havePlans
rules:
  apis-json-specification-version-error:
    description: Specification Version
    message: There MUST BE a specification version.
    severity: error
    given: $
    then:
      field: specificationVersion
      function: truthy
  apis-json-specification-version-info:
    description: Specification Version
    message: There is a specification version.
    severity: info
    given: $
    then:
      field: specificationVersion
      function: falsy
  apis-json-specification-aid-warn:
    description: Unique AID
    message: There COULD BE a unique aid.
    severity: warn
    given: $
    then:
      field: aid
      function: truthy
  apis-json-specification-aid-info:
    description: Unique AID
    message: There is a unique aid.
    severity: info
    given: $
    then:
      field: aid
      function: falsy
  apis-json-name-error:
    description: Name
    message: This resource MUST HAVE a name.
    given: $
    severity: info
    then:
      field: name
      function: truthy
  apis-json-name-info:
    description: Name
    message: This resource has a name.
    given: $
    severity: info
    then:
      field: name
      function: falsy
  apis-json-specification-type-error:
    description: Resource Type
    message: This MUST HAVE a type.
    severity: error
    given: $
    then:
      - field: type
        function: truthy
  apis-json-specification-type-info:
    description: Resource Type
    message: This has a type.
    severity: info
    given: $
    then:
      - field: type
        function: falsy
  apis-json-specification-type-value-error:
    description: Resource Type Value
    message: This MUST BE of type resource.
    severity: error
    given: $
    then:
      function: pattern
      functionOptions:
        match: \b(resource|Resource)\b
  apis-json-specification-type-value-info:
    description: Resource Type Value
    message: This is of type resource.
    severity: info
    given: $
    then:
      function: pattern
      functionOptions:
        notMatch: \b(resource|Resource)\b
  apis-json-description-error:
    description: Resource Description
    message: There MUST BE a description.
    given: $
    severity: error
    then:
      field: description
      function: truthy
  apis-json-description-info:
    description: Resource Description
    message: There is a description.
    given: $
    severity: info
    then:
      field: description
      function: falsy
  apis-json-image-error:
    description: Image
    message: There COULD BE an image.
    given: $
    severity: warn
    then:
      field: image
      function: truthy
  apis-json-image-info:
    description: Image
    message: There is an image.
    given: $
    severity: info
    then:
      field: image
      function: falsy
  apis-json-created-error:
    description: Created Date
    message: There MUST BE a created date.
    given: $
    severity: error
    then:
      field: created
      function: truthy
  apis-json-created-info:
    description: Created Date
    message: There is a created date.
    given: $
    severity: info
    then:
      field: created
      function: falsy
  apis-json-modified-error:
    description: Modified Date
    message: There MUST BE a modified date.
    given: $
    severity: error
    then:
      field: modified
      function: truthy
  apis-json-modified-info:
    description: Modified Date
    message: There is a modified date.
    given: $
    severity: info
    then:
      field: modified
      function: falsy
  apis-json-maintainers-error:
    description: Maintainer
    message: There MUST BE a maintainer.
    given: $
    severity: error
    then:
      field: maintainers
      function: truthy
  apis-json-maintainers-info:
    description: Maintainer
    message: There is a maintainer.
    given: $
    severity: info
    then:
      field: maintainers
      function: falsy
  apis-json-maintainers-fn-error:
    description: Maintainer FN
    message: There MUST BE a FN property for maintainers.
    given: $.maintainers.*
    severity: error
    then:
      field: FN
      function: truthy
  apis-json-maintainers-fn-info:
    description: Maintainer FN
    message: There is a FN property for maintainers.
    given: $.maintainers.*
    severity: info
    then:
      field: FN
      function: falsy
  apis-json-maintainers-email-error:
    description: Maintainer Email
    message: There MUST BE a email property for maintainers.
    given: $.maintainers.*
    severity: error
    then:
      field: email
      function: truthy
  apis-json-maintainers-email-info:
    description: Maintainer Email
    message: There is a email property for maintainers.
    given: $.maintainers.*
    severity: info
    then:
      field: email
      function: falsy
  apis-json-tags-error:
    description: Tags
    message: There MUST BE tags.
    given: $
    severity: error
    then:
      field: tags
      function: truthy
  apis-json-tags-info:
    description: Tags
    message: There are tags.
    given: $
    severity: info
    then:
      field: tags
      function: falsy
  apis-json-tags-upper-case-error:
    description: Tags Casing
    message: First letter of each word in tags need to be upper case.
    severity: error
    given: $.tags.*
    then:
      function: pattern
      functionOptions:
        match: "[A-Z]\\w*"
  apis-json-tags-upper-case-info:
    description: Tags CAsing
    message: First letter of each word in tags are upper case.
    severity: info
    given: $.tags.*
    then:
      function: pattern
      functionOptions:
        notMatch: "[A-Z]\\w*"
  apis-json-url-error:
    description: URL
    message: There MUST BE a URL.
    given: $
    severity: error
    then:
      field: url
      function: truthy
  apis-json-url-info:
    description: URL
    message: There is a URL.
    given: $
    severity: info
    then:
      field: url
      function: falsy
  apis-json-apis-aid-error:
    description: API AID
    message: APIs SHOULD HAVE a unique aid property.
    given: $.apis.*
    severity: warn
    then:
      field: aid
      function: truthy
  apis-json-apis-aid-info:
    description: API AID
    message: API have a unique aid property.
    given: $.apis.*
    severity: info
    then:
      field: aid
      function: falsy
  apis-json-apis-description-info:
    description: Each API included in an APIs.json file should have a 1-3 paragraph
      description. This description serves as the first impression for potential
      consumers and is often displayed in portals, networks, search results, and
      other discovery channels. A well-crafted description plays a key role in
      helping API consumers understand and onboard with the API effectively.
    message: Has a Description
    given: $.apis.*
    severity: info
    then:
      field: description
      function: falsy
  apis-json-apis-baseURL-error:
    description: Each API defined within an APIs.json artifact can specify the base
      URL for the API. This URL serves as a reference point for developers
      during onboarding and when making API calls. Additionally, it helps
      identify the API and validate the domain it is associated with.
    message: APIs MUST Have a Base URL
    given: $.apis.*
    severity: error
    then:
      field: baseURL
      function: truthy
  apis-json-apis-baseURL-info:
    description: Each API defined within an APIs.json artifact can specify the base
      URL for the API. This URL serves as a reference point for developers
      during onboarding and when making API calls. Additionally, it helps
      identify the API and validate the domain it is associated with.
    message: APIs Has a Base URL
    given: $.apis.*
    severity: info
    then:
      field: baseURL
      function: falsy
  apis-json-apis-humanURL-info:
    description: The humanURL property for each API defined in an APIs.json contract
      provides a link for business or technical consumers to learn more about
      the API. This URL can direct users to a portal, documentation, or ideally,
      a dedicated landing page designed specifically to onboard consumers with a
      single API.
    message: Has a Human URL
    given: $.apis.*
    severity: info
    then:
      field: humanURL
      function: falsy
  apis-json-apis-image-info:
    description: Each API defined within an APIs.json file can include a dedicated
      image, offering a visual representation of the resource or capability it
      provides. This enhances the API's approachability and visual appeal in
      portals, documentation, catalogs, and marketplaces, making it more
      engaging for potential users.
    message: Has an Image
    given: $.apis.*
    severity: info
    then:
      field: image
      function: falsy
  apis-json-apis-info:
    description: The APIs property in an APIs.json file enables the definition of
      one or more APIs as part of a larger collection. Each API within this
      property has its own subset of metadata, allowing it to be uniquely
      identified and distinguished from the rest of the collection. This
      individual metadata contributes to the overall value and functionality of
      the API collection.
    message: Has APIs
    given: $
    severity: info
    then:
      field: apis
      function: falsy
  apis-json-apis-name-info:
    description: Each individual API in an APIs.json collection has its own name
      property, allowing for a clear description of the API. This name might
      match the API's title in the OpenAPI Info section, but it could also
      represent the API's business purpose, as displayed in catalogs and search
      results.
    message: Has a Name
    given: $.apis.*
    severity: info
    then:
      field: name
      function: falsy
  apis-json-apis-tags-error:
    description: Each API defined in an APIs.json artifact includes a property for
      adding one or more tags. These tags provide additional context about the
      resources or capabilities offered by the API, highlighting its business
      value and the domain in which it is applied.
    message: API MUST Have a Tags Object
    given: $.apis.*
    severity: info
    then:
      field: tags
      function: truthy
  apis-json-apis-tags-info:
    description: Each API defined in an APIs.json artifact includes a property for
      adding one or more tags. These tags provide additional context about the
      resources or capabilities offered by the API, highlighting its business
      value and the domain in which it is applied.
    message: API Have a Tags Object
    given: $.apis.*
    severity: info
    then:
      field: tags
      function: falsy
  apis-json-apis-tags-upper-case-error:
    description: Maintaining consistent casing for tags applied to individual APIs
      ensures a uniform appearance and enhances search and discovery. Each word
      in a tag should be capitalized, with the first letter of every word in a
      phrase treated the same way.
    message: API Tags MUST Be Upper Case
    severity: error
    given: $.apis.*.tags.*
    then:
      function: pattern
      functionOptions:
        match: "[A-Z]\\w*"
  apis-json-apis-tags-upper-case-info:
    description: Maintaining consistent casing for tags applied to individual APIs
      ensures a uniform appearance and enhances search and discovery. Each word
      in a tag should be capitalized, with the first letter of every word in a
      phrase treated the same way.
    message: API Tags are Upper Case
    severity: info
    given: $.apis.*.tags.*
    then:
      function: pattern
      functionOptions:
        notMatch: "[A-Z]\\w*"
  apis-json-apis-properties-error:
    description: API Properties
    message: Resources MUST HAVE properties.
    severity: error
    given: $.apis.*
    then:
      field: properties
      function: truthy
  apis-json-apis-properties-info:
    description: API Properties
    message: Resource has properties.
    severity: info
    given: $.apis.*
    then:
      field: properties
      function: falsy
  apis-json-apis-properties-type-error:
    description: API Property Type
    message: Resources MUST HAVE properties type.
    severity: error
    given: $.apis.*.properties.*
    then:
      field: type
      function: truthy
  apis-json-apis-properties-type-info:
    description: API Property Type
    message: Resource has property type.
    severity: info
    given: $.apis.*.properties.*
    then:
      field: type
      function: falsy
  apis-json-apis-properties-type-value-error:
    description: Resource Type Value
    message: This MUST BE of type OpenAPI.
    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
    message: This is of the type OpenAPI.
    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
    message: Resources MUST HAVE properties data.
    severity: error
    given: $.apis.*.properties.*
    then:
      field: data
      function: truthy
  apis-json-apis-properties-data-info:
    description: API Property Type
    message: Resource has property type.
    severity: info
    given: $.apis.*.properties.*
    then:
      field: data
      function: falsy              

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

  apis-json-common-plans-error:
    description: Have Plans
    message: ""
    severity: warn
    given: $.common
    then:
      - field: common
        function: hello