Comments (10)
I assume this commit is what illustrates the issue
from express-zod-api.
![Screenshot 2024-05-16 at 01 19 21](https://private-user-images.githubusercontent.com/56695832/330941068-10a5a67a-224e-41b5-b083-e38f6e959743.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjUzMDA2OTgsIm5iZiI6MTcyNTMwMDM5OCwicGF0aCI6Ii81NjY5NTgzMi8zMzA5NDEwNjgtMTBhNWE2N2EtMjI0ZS00MWI1LWIwODMtZTM4ZjZlOTU5NzQzLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MDIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTAyVDE4MDYzOFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTA5ZmZmMmNkZWE1ZGU2MjQyOTU4YWRkMjFkN2M4OTVkZDNjM2NhMmFjOTg1Y2I4ZTg5ZTY5ODIxZWFhNzFjNjgmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.jGOo9MJLVo0R9ZAqjIVHC_gdmvqDNLJJySGCR1zAJVU)
![Screenshot 2024-05-16 at 01 18 15](https://private-user-images.githubusercontent.com/56695832/330941104-00603975-d104-4669-b5ed-800c74d0c435.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjUzMDA2OTgsIm5iZiI6MTcyNTMwMDM5OCwicGF0aCI6Ii81NjY5NTgzMi8zMzA5NDExMDQtMDA2MDM5NzUtZDEwNC00NjY5LWI1ZWQtODAwYzc0ZDBjNDM1LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MDIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTAyVDE4MDYzOFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTlkZDA3N2EwZmRmZTliZWNlMDNjOGYxNTJiNDllNjgwMjI1NjExNjlmMDZiZjNkYmRiYTRhNjQxNzhhZmVkNWUmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.FsOnme_f2QDhBeTcHT3Ou_PN5xmDpW8GUcSG8pXDSX4)
![Screenshot 2024-05-16 at 01 18 01](https://private-user-images.githubusercontent.com/56695832/330941112-afc60454-8c63-4ab9-9ac2-8b3b5262d0ed.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjUzMDA2OTgsIm5iZiI6MTcyNTMwMDM5OCwicGF0aCI6Ii81NjY5NTgzMi8zMzA5NDExMTItYWZjNjA0NTQtOGM2My00YWI5LTlhYzItOGIzYjUyNjJkMGVkLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MDIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTAyVDE4MDYzOFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWZkMTMyMDlkMTgxYjI0ZjM5Njc0MzkzZWQ2MDg1OTlhYWYxNmZhY2EzZjRhODlkYTgzZWZjZjU5ZDMyMjhkMzUmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.qCBllSinpC_HoT7tUxk7sarendC6Kzrox_liB-gEYZw)
![Screenshot 2024-05-16 at 01 22 05](https://private-user-images.githubusercontent.com/56695832/330941562-7943bfd5-83aa-4948-b6b1-b4738ea5fedf.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjUzMDA2OTgsIm5iZiI6MTcyNTMwMDM5OCwicGF0aCI6Ii81NjY5NTgzMi8zMzA5NDE1NjItNzk0M2JmZDUtODNhYS00OTQ4LWI2YjEtYjQ3MzhlYTVmZWRmLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MDIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTAyVDE4MDYzOFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTk2MWQ4YmE4YzdmZDUzNjYwZmRmNmNjYmZlMWFmYWJmN2M3OWZlN2MwYWZmYTg2MTMzOTU5ZDk0M2FkMjNjMjUmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.Yd3m-tihdsWfloIkOrcN2o4dKDKMy-nd0WmnwJem6sY)
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.
I see, it's duplicated, @boarush
Present in both "parameters" and the "body"
from express-zod-api.
I think that when getting the requestBody here, it needs to exclude the headers if they're enabled.
express-zod-api/src/documentation.ts
Lines 222 to 233 in 78ea9a8
from express-zod-api.
🚀 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.
@boarush , this line controls the appearance of the parameter in headers when you generate the documentation:
express-zod-api/src/documentation-helpers.ts
Lines 705 to 706 in 78ea9a8
Which means, as described in README, you should:
- Enable
headers
ininputSources
; - 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.
Ok. I need to make a test...
from express-zod-api.
On your screenshots both actually appear wrong, @boarush .
Even for GET request it says that the placement is query
, but it should be header
And that's very confusing, because for that case I already have a test.
from express-zod-api.
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
:
GET is absolutely correct, POST is showing double fields.
My bad, sorry for the confusion.
from express-zod-api.
Thank you so much for informing me and for the detailed explanation.
from express-zod-api.
Related Issues (20)
- Specifying input headers HOT 8
- TypeScript errors TS4023, TS4094 HOT 11
- Multiple servers in Swagger HOT 2
- Export request/response types from generated client HOT 5
- Listening to a configurable hostname HOT 1
- Insufficient types export (TS4023) of `Metadata` HOT 1
- Task: fix NPM warning during publishing
- Cannot create multiple errors response when generate Document
- Set schema name using withMeta
- Type regression from 16.1.0 to 16.2.0 HOT 3
- incorrect pattern field for openapi HOT 4
- What tool did you use to make the handdrawn diagram?
- OpenApi yaml spec has wrong minimum value for doubles HOT 6
- Allow all express-fileupload configurations HOT 5
- winston detetction not sufficient HOT 10
- tsc error when trying to build using the getting started instructions HOT 7
- Is it possible to add custom documentation generation for my custom zod types HOT 2
- Customising logger with winston erroring out in v19 HOT 17
- Default number range for `z.number()` causes `openapi-generator-cli generate` to fail HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from express-zod-api.