Forum Discussion

venkireddy1991's avatar
venkireddy1991
Occasional Contributor
4 years ago

validate OpenAPI Specification Document

Hi Team,

 

I got the Open API Specificatipon (.yaml) file from my de team,I would like to validate the Definition file against certain guide lines/styles/ruleset....

 

Could you please let me know how can do this with ready API Tool..

 

Note : I am able to verify this with other like like,Linters(Spectral,oval etc)....

 

Please suggest as soon as possible.

 

Thank you very much....

 

10 Replies

    • richie's avatar
      richie
      Community Hero
      Hi venkireddy1991

      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
      • venkireddy1991's avatar
        venkireddy1991
        Occasional Contributor

        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...