Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Ability to validate an endpoint #3

Open
simontabor opened this issue Dec 7, 2018 · 1 comment
Open

Feature Request: Ability to validate an endpoint #3

simontabor opened this issue Dec 7, 2018 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@simontabor
Copy link

I want to be really lazy and validate an entire endpoint (including parameters, which I don't think are supported at the moment).

Usage could look something like this:

const oas2joi = require('oas2joi');
const validator = oas2joi('./open-api.yml');
const { error } = validator('/my-endpoint', { params, body });
@JoeScho JoeScho self-assigned this Dec 16, 2018
@JoeScho JoeScho added the enhancement New feature or request label Dec 16, 2018
@JoeScho
Copy link
Owner

JoeScho commented Dec 16, 2018

Hey @simontabor , thanks for raising this.

I started looking into this, and before long realised that the function would require additional information such as the request method, and potentially content type, going from an OAS such as

/demo:
    post:
      summary: Demo
      description: Demo
      tags:
        - Demo
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/request'

Would it meet your requirements if this functionality were to be added as a middleware, like so:

const validator = require('oas2joi/validator');

// express app
app.use(validator('open-api.yml'));

So in each request, it validates using the request path, method, content-type (if present, default to application/json probably), body/params/query

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants