1
/example:    
      /{uriParams}:
        get:
          is: [defaultResponses, commonHeaders]
          uriParameters:
          uriParams:
          description: Example description uriParams
          body:
          application/json:
          example: !include examples.example.json

I would like creating the ruleset that checking the example !include and the traits (defaultResponse, commonHeaders) Now I have like this but this ruleset working separately.(It's mean that if I have ruleset with "traits" and "example" in the same file there is only working "traits". If I delete the ruleset from file "traits". It's working the ruleset "example".) But I would like that they working together. And also I'm trying doing ruleset for checking all fields are have name with camelCase example: "camelCase-exampleTwo"

    provide-examples:
        message: Always include examples in request and response bodies
        targetClass: apiContract.Payload
        rego: |
          schema = find with data.link as $node["http://a.ml/vocabularies/shapes#schema"]

          nested_nodes[examples] with data.nodes as object.get(schema, "http://a.ml/vocabularies/apiContract#examples", [])

   

          examples_from_this_payload = { element |
            example = examples[_]
            sourcemap = find with data.link as object.get(example, "http://a.ml/vocabularies/document-source-maps#sources", [])
            tracked_element = find with data.link as object.get(sourcemap, "http://a.ml/vocabularies/document-source-maps#tracked-element", [])
            tracked_element["http://a.ml/vocabularies/document-source-maps#value"] = $node["@id"]
            element := example
          }

          $result := (count(examples_from_this_payload) > 0)
   traits:
     message: common default
     targetClass: apiContract.EndPoint
     propertyConstraints:
        apiContract.ParametrizedTrait:
            core.name:
             pattern: defaultResponses

        camel-case-fields:
     message: Use camelCase.
     targetClass: apiContract.EndPoint
     if:
        propertyConstraints:
          shacl.name:
            in: ['path']
     then:
        propertyConstraints:
            shacl.name:
                pattern: "^[a-z]+([A-Z][a-z]+)*$"

aled
  • 21,330
  • 3
  • 27
  • 34
Anonim
  • 81
  • 5
  • What is making you think only one ruleset is working? – Harshank Bansal Jul 17 '22 at 05:38
  • @HarshankBansal I was remove the example !include and the traits from raml. And it's doesn't work together. And there was only one violations that missed the traits. But in my opinion it should also see that it missed the example !include. – Anonim Jul 17 '22 at 15:27
  • @Anonim not sure I understand what you are doing. Are you deleting files from the API Spec or are you deleting rulesets? There's no limitation (other than performance) to running 2 or more rulesets, each ruleset is independent from each other – Nicolas Schejtman Jul 20 '22 at 14:01
  • If you are modifying the API spec, it's expected that you will change the conformance against each ruleset. – Nicolas Schejtman Jul 20 '22 at 14:02

0 Answers0