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

Improve error messages when operation conversion fails #7

Merged
merged 1 commit into from
Sep 1, 2024

Conversation

john-shaffer
Copy link
Contributor

After upgrading to 0.0.6, I got NPEs with my existing OpenAPI definitions. Evidently there is a response in my code somewhere missing its schema, but it's difficult to track down where. To aid in debugging, I added the operationId to error messages. I also added a more clear error message when a schema is missing instead of letting it produce an NPE.

  • Wrap errors during operation processing in an ex-info. The message contains the operation name and the ex-data contains the source operation.
  • Throw ex-infos with a "missing schema" message instead of NPEs when a necessary schema is null.

This turns errors that previously looked like:
java.lang.NullPointerException: Cannot invoke "io.swagger.v3.oas.models.media.Schema.getTypes()" because "schema" is null
into this:
clojure.lang.ExceptionInfo: Exception processing operation "TestOp": Missing schema

- Wrap errors during operation processing in an
  ex-info. The message contains the operation name
  and the ex-data contains the source operation.
- Throw ex-infos with a "missing schema" message
  instead of NPEs when a necessary schema is null.

This turns errors that previously looked like:
`java.lang.NullPointerException: Cannot invoke "io.swagger.v3.oas.models.media.Schema.getTypes()" because "schema" is null`
into this:
`clojure.lang.ExceptionInfo: Exception processing operation "TestOp": Missing schema`
@lispyclouds
Copy link
Owner

Looks good, thanks a lot!

@lispyclouds lispyclouds merged commit 3fabb61 into lispyclouds:main Sep 1, 2024
@john-shaffer john-shaffer deleted the missing-schema-errors branch September 2, 2024 17:50
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

Successfully merging this pull request may close these issues.

2 participants