oscerd opened a new pull request, #27897:
URL: https://github.com/apache/camel/pull/27897

   ## Motivation
   
   In mock mode (`missingOperation=mock`), 
`DefaultRestOpenapiProcessorStrategy.loadMockData` falls back to the example of 
the `200` response when no mock file matches the request:
   
   ```java
   ApiResponse a = operation.getResponses().get("200");
   Content c = a.getContent();
   ```
   
   `a` is `null` for an operation whose responses have no `200` (for example 
only `201`, `204`, `default` or `2XX`), so the request fails with a 
`NullPointerException` instead of the documented "empty body with 204" 
behaviour. Reported by @Croway, reproduced with a GET of the petstore spec that 
has only a `default` response, no mock file, `missingOperation=mock`.
   
   ## Change
   
   Guard the null `200` response and treat it like a response without content, 
so mock mode answers `204` with an empty body (the existing no-content path).
   
   ## Testing
   
   
`RestOpenapiProcessorStrategyTest.testMockModeWithoutOkResponseReturnsEmpty204` 
calls `loadMockData` for an operation with only a `default` response and one 
with only a `201` response, asserting no exception and an empty `204` (both 
NPE'd before the fix). `camel-rest-openapi` build is green.
   
   _Claude Code on behalf of oscerd_
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to