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

Allow for serde_json::Value in body/return types #108

Merged
merged 2 commits into from
May 6, 2021
Merged

Conversation

ahl
Copy link
Collaborator

@ahl ahl commented May 6, 2021

Currently we fail on an unreachable!(): not quite true--obviously--since I forgot about permissive types such as serde_json::Value. This fix adds handling for that type. It also improves the panic message for the empty set type.

Note that I ran the resulting schema through openapi-generator and the model looks exactly as we would hope:

pub struct BodyParam {
    #[serde(rename = "_any")]
    pub _any: Option<serde_json::Value>,
    #[serde(rename = "_x")]
    pub _x: String,
}

(albeit with some extraneous renames... generated code, what can you do)

ahl added 2 commits May 6, 2021 13:38
thread 'test_openapi' panicked at 'internal error: entered unreachable code', dropshot/src/api_description.rs:643:46
@davepacheco
Copy link
Collaborator

LGTM -- fixes the bug I was seeing.

@davepacheco
Copy link
Collaborator

Seems like we can probably skip a change log entry for this, too.

@ahl
Copy link
Collaborator Author

ahl commented May 6, 2021

We could add: the use of permissive schemas (e.g. serde_json::Value) in API types is allowed

@ahl ahl merged commit bdbda2f into main May 6, 2021
@ahl ahl deleted the wheres_the_any_key branch May 6, 2021 21:53
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

Successfully merging this pull request may close these issues.

2 participants