Skip to content
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

Parser (v3) doesn't handle "enum" when "format" demands decoding a string #1049

Closed
kerrykimbrough opened this issue Mar 23, 2019 · 4 comments

Comments

@kerrykimbrough
Copy link
Contributor

See attached example. Consider the schema for param0, which has type=string and format=date-time.

Because of this format, an instance of DateTimeSchema is created. Then to handle the "enum" array, OpenAPIDeserializer.getSchema() iterates over each TextNode in the array, calling DateTimeSchema.addEnumItemObject() with the corresponding String value. This invokes DateTimeSchema.cast(), which should decode the String as an RFC3339 date-time.

But it doesn't. Instead, since a String is not a Date, it just substitutes null. Yikes!

The same problem occurs with other string formats that required decoding, specifically "byte" and "date".

string-8.json.txt

@kerrykimbrough
Copy link
Contributor Author

Found in 2.0.9

@gracekarina
Copy link
Contributor

Hi @kerrykimbrough can you please send us a PR to speed things up, if you have a possible solution, if you don't just a PR with a test which should fail until fixed. Thanks.

@kerrykimbrough
Copy link
Contributor Author

OK, PR is on the way

kerrykimbrough added a commit to kerrykimbrough/swagger-parser that referenced this issue Mar 26, 2019
…atted string values using getDecodedObject()
gracekarina added a commit that referenced this issue Apr 13, 2019
(issue #1049) OpenAPIDeserializer: Rework handling of formatted string values using getDecodedObject()
@gracekarina
Copy link
Contributor

closed by #1062

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants