Skip to content

Implement additional format: byte #1055

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

Closed
wing328 opened this issue May 10, 2015 · 9 comments
Closed

Implement additional format: byte #1055

wing328 opened this issue May 10, 2015 · 9 comments

Comments

@wing328
Copy link
Contributor

wing328 commented May 10, 2015

Currently, byte (format) is treated as "string" and there's a TODO in StringProperty to implement additional formats.

If no concern from anyone, I'll update the code to support byte as a property.

@webron
Copy link
Contributor

webron commented May 10, 2015

@wing328 - not really sure what's missing.. byte is treated as a valid format there.

@wing328
Copy link
Contributor Author

wing328 commented May 10, 2015

@webron If you look at the folder containing the StringProperty.java, it has "DateTimeProperty.java" but no "ByteProperty.java" (both have type set to string)

if("string".equals(type) && (format == null || "uri".equals(format) || "byte".equals(format)))

The above line checks type and format to determine if a property is a string. I think the TODO refers to implementing byte as a property itself (instead of treating byte as string)

In swagger-codegen, a response (type: string, format: byte) will always map to string. Ideally one can map it manually to something else (e.g. byte[]) using typeMapping.

@webron
Copy link
Contributor

webron commented May 10, 2015

Fair enough. However, as mentioned in one of the codegen comments, byte format is intended to be a Base64 encoded string, hence the string type. I'm not sure that would solve the issue that led you here.

@wing328
Copy link
Contributor Author

wing328 commented May 11, 2015

I would recommend updating the comment section on Swagger Spec 2.0 Data Types to mention about Base64-encoded string for byte

@webron
Copy link
Contributor

webron commented May 11, 2015

@wing328 - can you open an issue about it on swagger-spec? I want to make sure that this was indeed the intent.

@wing328
Copy link
Contributor Author

wing328 commented May 11, 2015

@webron shall we resume the conversation in OAI/OpenAPI-Specification#50 to confirm ?

@webron
Copy link
Contributor

webron commented May 11, 2015

@wing328 - sure. That issue was originally opened for 1.2, but it applies to 2.0 just as well.

@fehguy
Copy link
Contributor

fehguy commented May 20, 2015

I'm closing this out as it's a spec issue, and has a corresponding issue in that repo.

@fehguy fehguy closed this as completed May 20, 2015
@wing328
Copy link
Contributor Author

wing328 commented May 20, 2015

Totally agree.

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

3 participants