Skip to content

Commit

Permalink
Merge pull request #42 from djayakumar122/main
Browse files Browse the repository at this point in the history
Update OpenApiToJsonSchema.java
  • Loading branch information
yarg0007 committed Jan 12, 2024
2 parents 89f41a8 + f3f2fed commit 28a1429
Showing 1 changed file with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -179,15 +179,19 @@ public void convert() {
if (response == null) {
throw new IllegalStateException(String.format("Status code [%s] is not present for request method [%s] and path [%s] in file: %s", statusCode, requestMethod, requestPath, openApiSpecFilePath));
}

MediaType mediaType = response.getContent().get(MEDIA_TYPE);
if (mediaType == null) {
throw new IllegalStateException(
"Media type [application/json] is not present for status code [200] and request method ["
+ requestMethod + "] and path [" + requestPath + "] in file: " + openApiSpecFilePath);

//added below check to fix NPE
if(response.getContent() != null) {
MediaType mediaType = response.getContent().get(MEDIA_TYPE);
if (mediaType == null) {
throw new IllegalStateException(
"Media type [application/json] is not present for status code [200] and request method ["
+ requestMethod + "] and path [" + requestPath + "] in file: " + openApiSpecFilePath);
}else{
schema = mediaType.getSchema();
}
}

schema = mediaType.getSchema();

if (schema == null) {
throw new IllegalStateException(
"Schema not found for media type [application/json] and status code [200] and request method ["
Expand Down

0 comments on commit 28a1429

Please sign in to comment.