Forum Discussion

fmarchese's avatar
fmarchese
New Contributor
4 years ago

Create conditional custom standardization rule

Hi all,

 

We are trying to create custom standardization rules in swaggerhub but want them to apply only when the path exist.

This means that we may want to create a custom rule to apply, for example, to all POST methods in all apis, but we don't want it to fail in case the api does not have any POST method declared.

Is there a way to do this using swaggerhub custom rules or this is just not possible using rules?

 

Thanks in advance

  • Custom rules come in 2 basic flavors: 

    1. Path must exist (no regex)

    2. If a path exists, apply regex (matching or not matching)

     

    You should be able to craft a POST rule of type 2. This rule will apply only when a POST is found. 

     

    A POST rule of type 1 would require that the POST exists and could then be followed up with a second rule of type 2 to apply regex to the required POST. 

     

    • fmarchese's avatar
      fmarchese
      New Contributor

      thanks for the quick reply mhiggins , but when we create a custom rule only for POST responses for example, and select an api to test it that has no POST methods it returns an error like this:

       

      Maybe I am doing something wrong.

       

      Thanks in advance

       

      • mhiggins's avatar
        mhiggins
        Staff

        type this and build up from there..... (attached)