Skip to content

Commit

Permalink
Updated the test files as per PR changes
Browse files Browse the repository at this point in the history
The requestBody is made inline same as its done for responses and thus we'd need to look for contents inside it and not for the ref.
  • Loading branch information
mma5997 authored and frantuma committed Apr 27, 2022
1 parent 4c185fd commit a54bba6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import io.swagger.v3.oas.models.PathItem;
import io.swagger.v3.oas.models.media.ArraySchema;
import io.swagger.v3.oas.models.media.ComposedSchema;
import io.swagger.v3.oas.models.media.ObjectSchema;
import io.swagger.v3.oas.models.media.Schema;
import io.swagger.v3.parser.OpenAPIV3Parser;
import io.swagger.v3.parser.core.models.ParseOptions;
Expand Down Expand Up @@ -235,9 +236,9 @@ public void testIssue421() {
assertNotNull(swagger.getPaths().get("/pet/{petId}").getPost().getParameters());
assertTrue(swagger.getPaths().get("/pet/{petId}").getPost().getParameters().size() == 1);
assertTrue(swagger.getPaths().get("/pet/{petId}").getPost().getRequestBody() != null);
assertTrue(swagger.getPaths().get("/pet/{petId}").getPost().getRequestBody().get$ref() != null);
assertEquals(swagger.getPaths().get("/pet/{petId}").getPost().getRequestBody().get$ref(),"#/components/requestBodies/requestBody");
assertTrue(swagger.getPaths().get("/pet/{petId}").getPost().getRequestBody().get$ref().equals("#/components/requestBodies/requestBody"));
assertTrue(swagger.getPaths().get("/pet/{petId}").getPost().getRequestBody().getContent() != null);
assertTrue(swagger.getPaths().get("/pet/{petId}").getPost().getRequestBody().getContent().get("application/x-www-form-urlencoded") != null);
assertTrue(swagger.getPaths().get("/pet/{petId}").getPost().getRequestBody().getContent().get("application/x-www-form-urlencoded").getSchema() instanceof ObjectSchema);

assertNotNull(swagger.getPaths().get("/store/order"));
assertNotNull(swagger.getPaths().get("/store/order").getPost());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,9 @@ public void componentsResolver() throws Exception {
// internal callback reference
assertEquals(callbacks.get("referenced").get$ref(),"#/components/callbacks/failed");
//callback pathItem -> operation ->requestBody
assertEquals(callbacks.get("heartbeat").get("$request.query.heartbeat-url").getPost().getRequestBody().get$ref(),"#/components/requestBodies/requestBody3");
assertTrue(callbacks.get("heartbeat").get("$request.query.heartbeat-url").getPost().getRequestBody().getContent() != null);
assertTrue(callbacks.get("heartbeat").get("$request.query.heartbeat-url").getPost().getRequestBody().getContent().get("application/json").getSchema() instanceof ArraySchema);
assertEquals(((ArraySchema) callbacks.get("heartbeat").get("$request.query.heartbeat-url").getPost().getRequestBody().getContent().get("application/json").getSchema()).getItems().get$ref(),"#/components/schemas/User");
//remote callback ref
assertEquals(callbacks.get("remoteCallback").get$ref(),"#/components/callbacks/callback");

Expand Down

0 comments on commit a54bba6

Please sign in to comment.