Skip to content

Rule to Validate Schema Data Types Based on Paths #2300

Answered by blueksy1012
blueksy1012 asked this question in Q&A
Discussion options

You must be logged in to vote

Update: I found a way to do this after more research online:

Rules:

#This rule finds GET paths without the /id (ex. GET resources/) and ensures that the schema for the 200 response returns type "array".

schemas-return-array-data-types-when-expected:
description: Schemas should return the correct data types
message: "{{error}} : '{{path}}' (Schemas should return the correct data types. See API Standards page in Confluence (Route Verb Purposes section) for more information.)"
severity: warn
given:
$.paths[?( @property.match('^((?!.}$).)$') )].get.responses['200'][[schema]]
then:
field: type
function: pattern
functionOptions:
match: "array"

#This rule ensures that certain paths return "objec…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by blueksy1012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant