Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 handlers to return user-defined error types #1180
base: main
Are you sure you want to change the base?
Allow handlers to return user-defined error types #1180
Changes from 19 commits
af226ea
4d7c3e4
5bd7e3d
2eff88a
f2c7f5f
8da1c05
86b3afb
1f611bf
90e7247
06a1af3
6de6de3
cc4a2b9
c513c46
cfc582b
3d0575c
6b4b6d4
5f374b8
53ed323
ab798a9
e87ad82
6c9c824
10a4a99
b9f194c
576ba5f
8a4d52f
f9642d1
8f6d70e
ccbbbe2
46b4df1
00bcea7
a6c3472
4c93e2e
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
Alternatively, we could have added to
components.responses
as before and then referenced that. I can see the inline approach you've taken as potentially simpler, though it does bloat up the json output...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.
So, I'd like to put them in
components.responses
, too. The reason I didn't is that it might be a bit annoying to determine the name for each response schema.schemars
internally disambiguates colliding schema names by turning subsequent ones into likeError2
or whatever, but (AFAICT) we only get that when we actually generate the schema and it gives us back a reference (intocomponents.schemas
). We could then try to parse that reference and get the name back out to then use it to generate acomponents.responses
entry for that response, which seems possible, I just thought it seemed annoying enough that I didn't really want to bother with it. Do you think it's worth doing?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.
What if we name the response based on
<T as JsonSchema>::schema_name()
? Might that work?Do I think it's worth doing? I think it's worth trying. It might make the code worse, but it might make the output simpler. At a minimum it will make the diffs against current json simpler. These together--I think--at least warrant giving it a shot.
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 don't believe that deduplication is applied to
JsonSchema::schema_name()
; asfar as I can tell, it only happens once a schema has already been generated,
because that's when the generator can check if the name already exists in the
set of schemas that have been generated so far?