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

Invalid request body 400 error schema omits error property #175

Closed
markedwards opened this issue Aug 6, 2024 · 3 comments
Closed

Invalid request body 400 error schema omits error property #175

markedwards opened this issue Aug 6, 2024 · 3 comments

Comments

@markedwards
Copy link

The generated OpenAPI schema for a 400 error includes only the message property, but there is also an errors property with a lot of interesting information. Is there a reason why this property is not included in these generated errors?

Also, is there any way to have the request validation trigger informative logging in Next?

The issue I'm facing is there is a periodic invalid request body. The error is not logging in the API server, and because the errors property is not in the schema its not logged in the generated client either.

@blomqma
Copy link
Owner

blomqma commented Aug 26, 2024

Thanks, I have created an improvement for this by including the Zod error schemas for request bodies, query parameters etc. are automatically included in the auto-generated OpenAPI spec when the schemas have been defined for the endpoints: #177 (released in v6.0.2).

Fine-grained logging is something that has been asked for several times, I could try to come up with some solution that allows setting different logging levels for logging any validation errors returned by Next REST Framework.

@blomqma blomqma closed this as completed Aug 26, 2024
@markedwards
Copy link
Author

markedwards commented Aug 27, 2024

@blomqma Thanks for working on this. I still only see this in the error schemas:

      "Create an insights job400ResponseBody": {
        "type": "object",
        "properties": { "message": { "type": "string" } },
        "required": ["message"],
        "additionalProperties": false
      },

There is actually also an "errors" property in the error responses, with a lot of detail on what was specifically invalidated. This is the property I'm after.

@markedwards
Copy link
Author

So just to be clear, I'm using v6.0.2 and there is still no errors property. Can we follow up on this issue? Should I make a new issue?

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

No branches or pull requests

2 participants