ecyrbe / zodios

typescript http client and server with zod validation
https://www.zodios.org/
MIT License
1.71k stars 46 forks source link

[Improve documentation] advertise more explicitly that you don't need to declare path parameters #138

Closed thelinuxlich closed 2 years ago

thelinuxlich commented 2 years ago

Something like:

apiBuilder({
    method: 'get',
    path: '/orders/:order/status',
    alias: 'getStatusOrder',
    parameters: [
      {
        type: 'Path',
        name: 'order',
        schema: z.string(),
      },
    ],
    response: {
      schema: OrdersGetStatusOutputSchema,
    },
  })
thelinuxlich commented 2 years ago

Nevermind, I just looked at the tests and saw we don't need to define a param in this case, it's passed as the second parameter for the route. So what's missing is a small tip about it on the docs.

ecyrbe commented 2 years ago

yes, i will make it more explicit in the docs that path params are deduced implicitly and that you need to provide them in params attribute.

ecyrbe commented 2 years ago

example on how to call it

client.getStatusOrder({ params: { order : 5678 } });
ecyrbe commented 2 years ago

@thelinuxlich could you hint me where in the documentation you think this information would be more helpfull ?

thelinuxlich commented 2 years ago

https://www.zodios.org/docs/client#zodiosalias

ecyrbe commented 2 years ago

@thelinuxlich done. Maybe i over did it. added more examples and added a note.

Here for each call and at the first example: https://www.zodios.org/docs/client

And here on API definition: https://www.zodios.org/docs/api/api-definition#parameters

Closing.