Support a group of responses having different types across status codes, emitting an enum - #1422
Open
requiel20 wants to merge 1 commit into
Open
Conversation
…es, emitting an enum Closes oxidecomputer#344. Also fixes the reports in oxidecomputer#693, oxidecomputer#950 and oxidecomputer#1155. A group carrying more than one type now generates an enum with a variant per status code. The enums live in a `response` module, one submodule per operation, so an operation that varies both halves reads as `response::get_ready::Success` and `response::get_ready::Error`. A group of one type still names that type directly, so **no existing golden file changes** and no generated crate anywhere is affected. This PR supersedes oxidecomputer#857, by working on its review notes: - the generated types are in their own module, in the `response::operation_id::Success` shape suggested there; - errors are covered as well as successes; - the new concept lives inside `extract_responses` rather than beside it; - there is a test whose generated output is compiled, not only compared. The last of those needs oxidecomputer#1421 first: `progenitor-impl/tests/output` has not compiled for months, so on current main the new golden file is checked as text only. This change does not depend on that one however, strictly speaking.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Closes #344. Also fixes the reports in #693, #950 and #1155.
A group carrying more than one type now generates an enum with a variant
per status code. The enums live in a
responsemodule, one submodule per operation,so an operation that varies both halves reads as
response::get_ready::Successand
response::get_ready::Error.A group of one type still names that type directly, so no existing golden file changes
and no generated crate anywhere is affected.
Generated code:
Usage:
This PR supersedes #857, by working on its review notes:
response::operation_id::Successshape suggested there;
extract_responsesrather than beside it;The last of those needs #1421 first:
progenitor-impl/tests/outputhas not compiled formonths, so on current main the new golden file is checked as text only. This change does
not depend on that one however, strictly speaking.