Giter Club home page Giter Club logo

Comments (8)

andnilsson avatar andnilsson commented on September 3, 2024 1

very impressive :D

from express-zod-api.

andnilsson avatar andnilsson commented on September 3, 2024

To be more clear, I´m looking for a way to specify input like this x-header-param open-api snippet:

/path:
    get:
      parameters:
        - name: x-header-param
          in: header
          required: true
          schema:
            type: string
        - name: otherProp
          in: query
          required: false
          schema:
            type: boolean
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ResponeDefinition'

from express-zod-api.

RobinTail avatar RobinTail commented on September 3, 2024

You'd need to make a middleware, that inspects the request headers. The middleware should return an object that becomes "options" parameter for the endpoint's handler. This way you can provide the data acquired from headers to the endpoints, in case the headers carry out more than authentication. @andnilsson

from express-zod-api.

RobinTail avatar RobinTail commented on September 3, 2024

To be more clear, I´m looking for a way to specify input like this x-header-param open-api snippet

parameters:

  • name: x-header-param
    in: header

Currently headers are not considered as an input source for request parameters, but only as a way of authentication, that's why they are only available for describing as a part of security schemas in OpenAPI.
I understand your need, though I never experienced such a requirement. I need to check if OpenAPI even allows such ways of describing parameter location as header. @andnilsson

from express-zod-api.

RobinTail avatar RobinTail commented on September 3, 2024

yeah, @andnilsson , I found it in the specification.
OpenAPI definitely has in: header.
I'd consider this as a feature request in this regard.

image

from express-zod-api.

RobinTail avatar RobinTail commented on September 3, 2024

If implementing this feature, it's going to be limited to the custom headers only (those beginning with X-).
I hope it suits your needs.
And most likely they will be converted to the lower case, @andnilsson

https://swagger.io/docs/specification/describing-parameters/#header-parameters

from express-zod-api.

andnilsson avatar andnilsson commented on September 3, 2024

It sure does, awesome!

from express-zod-api.

RobinTail avatar RobinTail commented on September 3, 2024

@andnilsson , the feature released in version 12.2.0 🚀

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.