Closed mostafa closed 3 months ago
master
Total Size Diff :warning: :chart_with_upwards_trend: +11.21 KB
Thanks for contributing, I'll take a look soon
for record: unit tests are 100% covered for buildOperationId()
@logto-io/eng calling for another review
@gao-sun I love your changes. 👌 Thank you!
Summary
This PR adds
operationId
to the each HTTP method on each endpoint. As per the specification, "operationId
is an optional unique string used to identify an operation. If provided, these IDs must be unique among all operations described in your API". This greatly simplifies the creation of client SDKs in different languages, because it generates more meaningful function names instead of auto-generated ones, like the following examples:Note for the Reviewer
I tried to make a uniform set of names based on the method and path, yet certain paths were duplicated due to their composition. For these cases I opted for custom names in a map and tried to copy the phrase from https://openapi.logto.io. The naming can be improved using a 1:1 mapping, but that's probably not the desired way to do this. I am not aware of other ways to achieve this in Zod or your project, and would be happy to know more if one exists. Also, I wanted to use route names, but they map to anonymous functions.
Testing
Search for
operationId
in the http://localhost:3002/api/swagger.json.Checklist
.changeset