-
Notifications
You must be signed in to change notification settings - Fork 71
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
Cannot use different type for HTTP 404. #928
Comments
That is messed up! This is, effectively, the result of a name conflict when making up names. (Note that naming being hard is issue oxidecomputer/typify#1 for a reason.) Because the types for https://github.com/oxidecomputer/typify/blob/main/typify-impl/src/lib.rs#L834-L846 This is lousy! There's work ongoing to fix this, but it's not going to be done imminently (candidly that part is a side project for me since it's not particularly relevant to our use of progenitor/typify at Oxide). See oxidecomputer/typify#579 and oxidecomputer/typify#195. There's an easy workaround that, I hope, might be viable for you: @@ -40,38 +40,42 @@
content:
application/json:
schema:
- type: object
- properties:
- data:
- type: object
- properties:
- key:
- $ref: "#/components/schemas/AnyJsonValue"
- value:
- $ref: "#/components/schemas/AnyJsonValue"
- required:
- - key
- - value
- meta:
- $ref: "#/components/schemas/AnyJsonValue"
- required:
- - data
+ $ref: "#/components/schemas/StateMapElementResponse2"
NotFound:
description: The requested resource was not found.
content:
application/json:
schema:
- type: object
- properties:
- errors:
- type: array
- items:
- $ref: "#/components/schemas/Error"
- meta:
- $ref: "#/components/schemas/AnyJsonValue"
- required:
- - errors
+ $ref: "#/components/schemas/NotFound"
schemas:
+ StateMapElementResponse2:
+ type: object
+ properties:
+ data:
+ type: object
+ properties:
+ key:
+ $ref: "#/components/schemas/AnyJsonValue"
+ value:
+ $ref: "#/components/schemas/AnyJsonValue"
+ required:
+ - key
+ - value
+ meta:
+ $ref: "#/components/schemas/AnyJsonValue"
+ required:
+ - data
+ NotFound:
+ type: object
+ properties:
+ errors:
+ type: array
+ items:
+ $ref: "#/components/schemas/Error"
+ meta:
+ $ref: "#/components/schemas/AnyJsonValue"
+ required:
+ - errors
AnyJsonValue:
description: "Any JSON type, including null."
nullable: true In short, name the types; this produces this: impl Client {
///get_state_element
///
///Sends a `GET` request to `/items/{key}`
pub async fn get_state_element<'a>(
&'a self,
key: &'a str,
) -> Result<ResponseValue<types::StateMapElementResponse2>, Error<types::NotFound>> { There's potentially some work we could do before the more significant restructuring to help here. For example, we could start to do a little name uniquification by checking to see if multiple responses are going to (or might) need generated named; in such a case, we could come up with unique names: https://github.com/oxidecomputer/progenitor/blob/main/progenitor-impl/src/method.rs#L478-L509 While naming uniqueness is a general (and generally annoying) problem. It might make sense to have a specific solution here since we have local context about how we might distinguish names. For good or ill, we've already resolved the Please let us know if the workaround suggested suffices or if some local name awareness would be helpful. |
Is this a duplicate of #344? |
I want to use progenitor, but generated client uses same response type for HTTP 404 as it has for HTTP 200.
Here is the most simple reproducible spec:
Here is part of the codegen.rs:
I am struggling to find what causes the problem, that Error variant is the same as success.
The text was updated successfully, but these errors were encountered: