Giter Club home page Giter Club logo

Comments (10)

RobinTail avatar RobinTail commented on September 3, 2024 1

I assume this commit is what illustrates the issue

ccc098e

from express-zod-api.

boarush avatar boarush commented on September 3, 2024 1
Screenshot 2024-05-16 at 01 19 21 Screenshot 2024-05-16 at 01 18 15 Screenshot 2024-05-16 at 01 18 01 Screenshot 2024-05-16 at 01 22 05

In the screenshots, you can see that I have specified the x-request-id header as input for both the GET and POST endpoint, however, one shows up correctly as a header in the swagger doc and one only as the part of request body.

I have tried setting the inputSources to explicitly include the header field and also using just the defaults, both result in the same generated doc.

Does this example make the problem clear?

from express-zod-api.

RobinTail avatar RobinTail commented on September 3, 2024 1

I see, it's duplicated, @boarush
Present in both "parameters" and the "body"

image

from express-zod-api.

boarush avatar boarush commented on September 3, 2024 1

I think that when getting the requestBody here, it needs to exclude the headers if they're enabled.

const requestBody = inputSources.includes("body")
? depictRequest({
...commonParams,
schema: endpoint.getSchema("input"),
mimeTypes: endpoint.getMimeTypes("input"),
description: descriptions?.requestBody?.call(null, {
method,
path,
operationId,
}),
})
: undefined;

from express-zod-api.

RobinTail avatar RobinTail commented on September 3, 2024 1

🚀 Should be fixed in v19.1.1, @boarush
In case it's not, please open another issue.
Thank you once again for your contribution!

from express-zod-api.

RobinTail avatar RobinTail commented on September 3, 2024

@boarush , this line controls the appearance of the parameter in headers when you generate the documentation:

const isHeaderParam = (name: string) =>
areHeadersEnabled && isCustomHeader(name);

Which means, as described in README, you should:

  1. Enable headers in inputSources;
  2. The header name should starts with x-.

In your commit first step is missing and that's why it's treated differently.
The step is missing, because you made changes to the example that is not configured to handle headers.

though after specifying the inputSources in the config, request works in both cases

So... What's the issue with setting inputSources?
Headers in input is the opt-in feature that you can enable that way.
Please clarify.

Thank you for the wonderful work! Really simple working with the library!

Thank you as well, appreciate it :)

from express-zod-api.

RobinTail avatar RobinTail commented on September 3, 2024

Ok. I need to make a test...

from express-zod-api.

RobinTail avatar RobinTail commented on September 3, 2024

On your screenshots both actually appear wrong, @boarush .
Even for GET request it says that the placement is query, but it should be header

image

And that's very confusing, because for that case I already have a test.

from express-zod-api.

boarush avatar boarush commented on September 3, 2024

I think I mixed up the screenshots, those were for when I was not including the inputSources. Following are for when I am including the inputSources:
Screenshot 2024-05-16 at 01 33 50
Screenshot 2024-05-16 at 01 33 44

GET is absolutely correct, POST is showing double fields.

My bad, sorry for the confusion.

from express-zod-api.

RobinTail avatar RobinTail commented on September 3, 2024

Confirmed, @boarush

Thank you so much for informing me and for the detailed explanation.

from express-zod-api.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.