-
-
Notifications
You must be signed in to change notification settings - Fork 14
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
Support custom primitive type formats #66
base: main
Are you sure you want to change the base?
Conversation
defp render_return_type([], _type_overrides), do: quote(do: :ok) | ||
defp render_return_type(_state, []), do: quote(do: :ok) |
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.
Sorry for going outside of this PR's limits, but shouldn't this clause check for the empty list on the second argument?
lib/open_api/processor/type.ex
Outdated
@type integer_format :: String.t() | ||
@type number_format :: String.t() |
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.
I haven't decided whether to add all the Decided to add integer
and number
formats mentioned in the OpenAPI specification (for "symmetry" with string
formats):
int32
andint64
forinteger
typefloat
anddouble
fornumber
type
| {:boolean, boolean_format} | ||
| :integer | ||
| {:integer, integer_format} | ||
| :number | ||
| {:number, number_format} |
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.
Do we still need an atom-type or should we use :generic
as a second tuple element as the "default" value?
This PR allows processing of custom formats for primitive types (
boolean
,integer
,number
andstring
). All non-null
formats will be stored in a tuple ({:string, "custom"}
).Examples:
DD.MM.YYYY
Y
/N
or1
/0
The new callback
OpenAPI.Renderer.render_type/2
(with the default implementation inOpenAPI.Renderer.Util.to_type/2
) is added to allow users to customize the formats' processing.