Alastair
Alastair

Reputation: 11

Creating custom rule for API Governance - How to check for traits?

I am creating a ruleset to validate my RAML specification in Design Center.

One of the rules I am creating is to check if a custom trait is being used for each resource. Here is a snippet of the RAML specification:

/ping:
  displayName: Application Status
  description: Current health
  is: [traceable, secured]

I want it to check that the secured trait is present in the is: tag. So far, I have not found a way to access the is: tag to be able to do this. I am using the AMF documentation found here: https://github.com/aml-org/amf/blob/develop/documentation/model.md#endpoint but it is not clear to me how I should approach this.

I have seen a few attempts posted on here trying to do the same thing and one such attempt is as follows:

  secured-tag-required:
    message: Secured trait is missing
    targetClass: apiContract.EndPoint
    propertyConstraints:
      apiContract.ParameterizedTrait:
        core.name:
          pattern: secured

This does not work. apiContract.ParameterizedTrait is not documented in the AML/AMF documentation either so I am unsure where it came from. See Creating custom ruleset for API Governance for a similar attempt

Is what I am doing possible? Any help is appreciated.

Upvotes: 1

Views: 84

Answers (0)

Related Questions