cancel
Showing results for 
Search instead for 
Did you mean: 

Create conditional custom standardization rule

fmarchese
New Contributor

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

3 REPLIES 3
mhiggins
Staff

Re: Create conditional custom standardization rule

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
New Contributor

Re: Create conditional custom standardization rule

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:

fmarchese_1-1616447260930.png

 

Maybe I am doing something wrong.

 

Thanks in advance

 

mhiggins
Staff

Re: Create conditional custom standardization rule

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

New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors