In my API I have a set of regex patterns that I use throughout the document
for the "pattern" field. I want to make some sort of a constant values that
I can re-use instead of having a bunch of copies of the same regex pattern.
This is for readability and to reduce the locations that have to be updated
if the regex is changed.
I've tried a few things. The most recent was to define an extension as
shown below. The example shows two ways that I tried to do it. The first
was just direct properties with values and the last one, "objected" was by
creating an extension called "x-val" so that I could specify the type as
"string.
Is there a way to do what I am trying to do with Swagger 2.0?
x-formatting:
username: "/^[A-Z0-9][A-Z0-9-]+[A-Z0-9]$/i"
targetname: "/^[A-Z0-9\\-\\._]+$/i"
groupname: "/^[A-Z0-9][A-Z0-9-]+[A-Z0-9]$/i"
email: "/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,20}$/i"
objectid:
type: string
x-val: "/^[0-9a-fA-F]{24}$/"
... and here are the attempted references
pattern:
$ref: "#/x-formatting/username"
pattern:
$ref: "#/x-formatting/objectid/x-val"
The error I am getting is that the pattern field is expecting a "string"
--
You received this message because you are subscribed to the Google Groups
"Swagger" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.