-
Notifications
You must be signed in to change notification settings - Fork 189
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adds features to example
functionality
#603
base: master
Are you sure you want to change the base?
Conversation
obj: anyOf: enum: - DSL - PON type: string
@@ -402,6 +402,10 @@ defmodule OpenApiSpex.Schema do | |||
def example(%Schema{type: :string, format: :"date-time"}), do: "2020-04-20T16:20:00Z" | |||
def example(%Schema{type: :string, format: :uuid}), do: "02ef9c5f-29e6-48fc-9ec3-7ed57ed351f6" | |||
|
|||
def example(%Schema{type: :string, pattern: regexp}) when is_binary(regexp), do: | |||
Randex.stream(Regex.compile!(regexp)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If randex
is an optional dependency, then this should have some runtime check for the Randex
module being loaded?
@@ -402,6 +402,10 @@ defmodule OpenApiSpex.Schema do | |||
def example(%Schema{type: :string, format: :"date-time"}), do: "2020-04-20T16:20:00Z" | |||
def example(%Schema{type: :string, format: :uuid}), do: "02ef9c5f-29e6-48fc-9ec3-7ed57ed351f6" | |||
|
|||
def example(%Schema{type: :string, pattern: regexp}) when is_binary(regexp), do: | |||
Randex.stream(Regex.compile!(regexp)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For this change to generate examples matching the schema, it must also take into account the minLength
and maxLength
properties. Does Randex
support such parameters?
Allows generation of context based on regexp
Allows for non object types anyOf's and oneOf's like