-
Notifications
You must be signed in to change notification settings - Fork 76
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
[FEATURE] Smithy mixin input and de-nested API call #460
Comments
Hey! I agree this would be a nicer interface! 😄 It might be a bit tricky to support however, as the client is generated by the The interface each client method takes accepts all the request parameters (ie path and query params), plus an argument for the request body, eg. an operation like "Unpacking" the body parameter might lead to naming conflicts for users using Since you're using Smithy, generating code directly from Smithy could be the way to create a more "user friendly" client however, as the generated code can align more closely to the Smithy model rather than the generated OpenAPI specification. There's a plugin called Perhaps this could be an option? You can customise Perhaps you could give that a try and see if it works nicely? If it's an improvement we could look at adding a developer guide to the docs which explains how to do it in more detail, or even look at building an option in to |
I'll try it out this weekend! Can't make any guarentees I'll succeed tho :P |
Keen to hear how you go! 😄 I might also give it a try over the next few days if I get a spare moment :) |
Had a bit of time this evening and had a go! Example repo here! https://github.com/cogwirrel/tsapi-smithy-client-example It seems to work alright! Note that the auth is built in to the generated client based on what you specify in your Smithy model, so you need eg I also extended that example out of curiosity to use the Smithy TypeScript Server SDK for implementing the lambda handlers :) Error handling in the Smithy generated client seems to be a little bit nicer when you use it in combination with the Smithy server sdk, as you can use Hope that helps :) |
…d client in handler wrappers Clients generated directly from Smithy (using the typescript-codegen plugin) can deserialise error responses into the appropriate generated model classes, but they do this by checking for a special `x-amzn-errortype` header. This change updates the generated handler wrappers to include the appropriate value for this header for error responses. Note that OpenAPI specs generated from Smithy add "ResponseContent" as a suffix to all response data types, so we remove this in order to match the appropriate error structure ID. If the response data type doesn't end with ResponseContent, it didn't come from Smithy so there's no need to return this header anyway. re #460
…d client in handler wrappers (#468) Clients generated directly from Smithy (using the typescript-codegen plugin) can deserialise error responses into the appropriate generated model classes, but they do this by checking for a special `x-amzn-errortype` header. This change updates the generated handler wrappers to include the appropriate value for this header for error responses. Note that OpenAPI specs generated from Smithy add "ResponseContent" as a suffix to all response data types, so we remove this in order to match the appropriate error structure ID. If the response data type doesn't end with ResponseContent, it didn't come from Smithy so there's no need to return this header anyway. re #460
#468 adds the error header expected by the Smithy generated client so that you don't lose out on better error handling when using the native type-safe-api handler wrappers. I think the final step for this issue would be to either:
I'm leaning towards (1), as (2) will add the challenge of keeping dependency versions in sync since we can't use the Smithy generated list of deps/devDeps in a projen |
This is a fine solution for me! It doesn't need to be fancy and the nesting isn't that big of a problem. |
Ah this doesn't only happen with mixins, but also with the shorthand operation syntax: @tags(["Journeys", "Qrd"])
@idempotent
@http(method: "POST", uri: "/qrds/safeqrd/activate")
operation ValidateTag {
input := {
@required
activationCode: String
}
output := {
@required
isValid: Boolean
}
}
I have to call this the following way: const isValid = await journeyClient.validateTag({
validateTagRequestContent: {
activationCode,
},
}); |
That key like It’s still on my todo list to document generating a client directly from Smithy (without going via OpenApi), which results in a client which has types that align much closer to the Smithy model :) |
I'm going to close this issue in favour of #687 - as it'd be great if we could natively generate Smithy clients/servers etc |
Describe the feature
If I have the following Smithy shapes:
And then generate the client, I have to call the
CreateCustomer
method as follows:The nesting is slightly annoying, is there anyway to get it flattened, so that the
{ name: ... }
could just be defined as the first parameter:The current case for is that I get the following error:
Use Case
I don't need it, it's just a nice to have :P.
Proposed Solution
No response
Other Information
Just do it the current way!
Acknowledgements
PDK version used
0.19.15
What languages will this feature affect?
Typescript
Environment details (OS name and version, etc.)
MacOS ARM64, Ventura
The text was updated successfully, but these errors were encountered: