openapistack / openapi-backend

Build, Validate, Route, Authenticate and Mock using OpenAPI
https://openapistack.co
MIT License
600 stars 82 forks source link

Multiple errors on request validation #726

Closed w3nl closed 1 month ago

w3nl commented 3 months ago

Hi,

I have enabled the request validation (https://openapistack.co/docs/openapi-backend/request-validation/) I have a post where I can submit a json object. It works nice, but it returns only a single error. If i solve this, it returns the other error. So it works good, only is my question, is it intended that it only returns a single error for a json object? Or can I also return multiple, is it something in the openapi-backend package, or is it because another dependency for the openapi validation?

ce2kettu commented 1 month ago

You could try customizing the ajv options with this https://ajv.js.org/options.html#allerrors

w3nl commented 1 month ago

Thanks, it works:

const api = new OpenAPIBackend({
    definition: openAPISpecification,
    strict: true,
    ajvOpts: { allErrors: true },
    customizeAjv: (originalAjv) => {
      addFormats(originalAjv)
      return originalAjv
    }
  })
w3nl commented 1 month ago

No changes needed for this package