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

No way to return just string in response #184

Open
serj-p opened this issue May 27, 2020 · 2 comments
Open

No way to return just string in response #184

serj-p opened this issue May 27, 2020 · 2 comments
Labels
enhancement New feature or request swagger-generation Concerns automatic swagger generation validation Concerns request and response validation

Comments

@serj-p
Copy link

serj-p commented May 27, 2020

i've searched through documentation of rebar, marshmallow and trhough open issues

it seems like there's no way to define an endpoint which would return not objects or lists of objects but primitive types, i.e. string, int etc, what is a valid json response. is it possible to add fields.String, etc support as response_body_schema?

@Sytten
Copy link

Sytten commented May 27, 2020

Honestly before you mentioned it, I never thought that a simple string was a valid JSON.
What is your usecase for it? I am not even sure marshmallow supports that.

@serj-p
Copy link
Author

serj-p commented May 29, 2020

I am rewriting my app from flask-restplus to rebar and I had an api endpoint api/get_recent_id which was returning whether json "RECENTID" or null if there was no recent one. on rebar there's only a possibility to return not None not marshmallow-validated primitive types specifying response_body_schema to None. null cannot be returned by design, because rebar returns empty content what is not a valid json and client would not understand it. So I ended up returning empty string.

@airstandley airstandley added enhancement New feature or request swagger-generation Concerns automatic swagger generation validation Concerns request and response validation labels Jul 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request swagger-generation Concerns automatic swagger generation validation Concerns request and response validation
Projects
None yet
Development

No branches or pull requests

3 participants