Forum Discussion
Just to reiterate what Rao has already stated and to add a bit of additional detail.
Using .json and .xml as an example, you get wellformed checks and valid checks.
Wellformed (which checks a file to ensure it corresponds to wellformed syntax rules (which is doneby the parser). Wellformed checks are done by the parser so no additional file is required. Simply put, the file to be checked by the parser is all thats required.
Valid checks (known as schema valid/invalid) check the content of a file conforms to rules defined in ANOTHER file (known as the schema) and these schema valid rules check content, format, datatypes, field lengths, value format/pattern etc. and all these rules are defined in the schema.
Quite often the terminology can be a confused....e.g. a lot of online json validators dont check for validation, they simply check to ensure the file is wellformed.....i.e. to check a file is valid on these online tools, youd have to load up the schema file first and then load of the file you want to ensure is valid and the tool would then compare the and file to ensure it conforms to the rules defined in your schema (the first file loaded in my example).
Your openAPI/swagger .json file is the definition (the schema itself) so you can only check the .yaml files wellformedness.
ReadyAPI! doesn't include a function to check wellformedness independently. The wellformed check is done by whichever ReadyAPI! Parser is executed when a file is loaded into ReadyAPI!
If the file loads with no errors being reported, by definition, the file has been parsed and checked for wellformedness and it has passed the wellformed check. Only if errors were reported (hindering successfully loading in your openAPI file) would the file be malformed.
As i said your file IS the schema so you can only check to ensure its not malformed.
Best case you can check the files youll be submitting against your openAPI .yaml (the schema) to ensure your files are schema valid.
Hope the above has clarified a bit,
Nice one,
Rich
Thank you for all your responses.
Wellformed checks (something like valid document format etx)can be done when you load the Spec file in the tools.(Ready API etc...)
Let us consider the beow Checks
1. Contact details shpuld have emai and phone number
2.should contains title and descriptions
3.Servers shoud not contain "\" at the end
4.Methods should be snake_case.....
etc..some thing like this....Before Dev team develops the APIs,as part of Testing team you need to ensure that they follow these guide lines while desining the Spec files...
I can actually use SwaggerCompliance assertion to veryfy the Responses are appropriate as per the Spec file...but this is after the Actual API Development is done...
Just looking for some thing in ready API to check the Spec files.(Something similar to the Spectral CLI or OVAL or Speccy)
Anyways I dont see I can do this with Ready API.....I will can continue doing with spectral and ensure the Spac file is true..
Our goal is to ensure the Spc file is single source of truth for Dev,QA or any other teams...
- richie5 years agoCommunity HeroHi venkireddy1991 ,
I appreciate this doesnt help with your problem...as you already state ReadyAPI! performs a wellformed check when you load in a file and each time the file is parsed, but i just wanted to mention the detail below as this might steer you in another direction.
The checks you mention in your last appear to a mix of what id consider as 'validation' along with a single 'wellformed' check.
I appreciate you want to ensure the developers code adheres to the rules defined in your openAPI .yaml, but whether this is actually necessary or not depends on how the developers are creating the apis themselves.
What i mean by this is there are tools out there that support the creation and update of the openAPI (.yaml) files. What i mean is there are tools such as Smartbears Swagger that allow the user to create your .yaml file and this .yaml file is then used by developers to create the code for the apis themselves (at least i think this is the way it works), so the .yaml is a framework and the apis defined in the .yaml can be generated dynamically from the .yaml. if this is the case (and i think it is from the reading i've just done) then checking the developed apis conform to the rules in the .yaml is moot because the .yaml was used to generate the apis themselves.
I hope ive been clear
Cheers
Rich- venkireddy19915 years agoOccasional Contributor
Team,
How can add swagger compliance assertion using script??
- HimanshuTayal5 years agoCommunity Hero
- nmrao5 years agoChampion Level 3The 4 points which are mentioned are very specific to your use case. This is actually something you want to have checks on metadata.
So I believe that one can write an utility to parse the yaml and have the desired checks.
Related Content
Recent Discussions
- 22 days ago