}
/**
- * Test that generated document contains the following definitions.
+ * Test that generated document contains the following schemas.
*/
@Test
- public void testDefinitions() {
+ public void testSchemas() {
final var module = CONTEXT.findModule(NAME, Revision.of(REVISION_DATE)).orElseThrow();
final OpenApiObject doc = generator.getOpenApiDocSpec(module, "http", "localhost:8181", "/", "", CONTEXT);
- final ObjectNode definitions = doc.getDefinitions();
- assertNotNull(definitions);
+ final ObjectNode schemas = doc.getComponents().getSchemas();
+ assertNotNull(schemas);
- final JsonNode configLstTop = definitions.get("toaster2_config_lst_TOP");
+ final JsonNode configLstTop = schemas.get("toaster2_config_lst_TOP");
assertNotNull(configLstTop);
DocGenTestHelper.containsReferences(configLstTop, "lst", "#/components/schemas/toaster2_config_lst");
- final JsonNode configLst = definitions.get("toaster2_config_lst");
+ final JsonNode configLst = schemas.get("toaster2_config_lst");
assertNotNull(configLst);
DocGenTestHelper.containsReferences(configLst, "lst1", "#/components/schemas/toaster2_lst_config_lst1");
DocGenTestHelper.containsReferences(configLst, "cont1", "#/components/schemas/toaster2_lst_config_cont1");
- final JsonNode configLst1Top = definitions.get("toaster2_lst_config_lst1_TOP");
+ final JsonNode configLst1Top = schemas.get("toaster2_lst_config_lst1_TOP");
assertNotNull(configLst1Top);
DocGenTestHelper.containsReferences(configLst1Top, "lst1", "#/components/schemas/toaster2_lst_config_lst1");
- final JsonNode configLst1 = definitions.get("toaster2_lst_config_lst1");
+ final JsonNode configLst1 = schemas.get("toaster2_lst_config_lst1");
assertNotNull(configLst1);
- final JsonNode configCont1Top = definitions.get("toaster2_lst_config_cont1_TOP");
+ final JsonNode configCont1Top = schemas.get("toaster2_lst_config_cont1_TOP");
assertNotNull(configCont1Top);
DocGenTestHelper.containsReferences(configCont1Top, "cont1", "#/components/schemas/toaster2_lst_config_cont1");
- final JsonNode configCont1 = definitions.get("toaster2_lst_config_cont1");
+ final JsonNode configCont1 = schemas.get("toaster2_lst_config_cont1");
assertNotNull(configCont1);
DocGenTestHelper.containsReferences(configCont1, "cont11",
- "#/components/schemas/toaster2_lst_cont1_config_cont11");
+ "#/components/schemas/toaster2_lst_cont1_config_cont11");
DocGenTestHelper.containsReferences(configCont1, "lst11",
- "#/components/schemas/toaster2_lst_cont1_config_lst11");
+ "#/components/schemas/toaster2_lst_cont1_config_lst11");
- final JsonNode configCont11Top = definitions.get("toaster2_lst_cont1_config_cont11_TOP");
+ final JsonNode configCont11Top = schemas.get("toaster2_lst_cont1_config_cont11_TOP");
assertNotNull(configCont11Top);
DocGenTestHelper.containsReferences(configCont11Top,
- "cont11", "#/components/schemas/toaster2_lst_cont1_config_cont11");
+ "cont11", "#/components/schemas/toaster2_lst_cont1_config_cont11");
- final JsonNode configCont11 = definitions.get("toaster2_lst_cont1_config_cont11");
+ final JsonNode configCont11 = schemas.get("toaster2_lst_cont1_config_cont11");
assertNotNull(configCont11);
- final JsonNode configLst11Top = definitions.get("toaster2_lst_cont1_config_lst11_TOP");
+ final JsonNode configLst11Top = schemas.get("toaster2_lst_cont1_config_lst11_TOP");
assertNotNull(configLst11Top);
DocGenTestHelper.containsReferences(configLst11Top, "lst11",
- "#/components/schemas/toaster2_lst_cont1_config_lst11");
+ "#/components/schemas/toaster2_lst_cont1_config_lst11");
- final JsonNode configLst11 = definitions.get("toaster2_lst_cont1_config_lst11");
+ final JsonNode configLst11 = schemas.get("toaster2_lst_cont1_config_lst11");
assertNotNull(configLst11);
}
/**
- * Test that generated document contains RPC definition for "make-toast" with correct input.
+ * Test that generated document contains RPC schemas for "make-toast" with correct input.
*/
@Test
public void testRPC() {
final OpenApiObject doc = generator.getOpenApiDocSpec(module, "http", "localhost:8181", "/", "", CONTEXT);
assertNotNull(doc);
- final ObjectNode definitions = doc.getDefinitions();
- final JsonNode inputTop = definitions.get("toaster_make-toast_input_TOP");
+ final ObjectNode schemas = doc.getComponents().getSchemas();
+ final JsonNode inputTop = schemas.get("toaster_make-toast_input_TOP");
assertNotNull(inputTop);
final String testString = "{\"input\":{\"$ref\":\"#/components/schemas/toaster_make-toast_input\"}}";
assertEquals(testString, inputTop.get("properties").toString());
- final JsonNode input = definitions.get("toaster_make-toast_input");
+ final JsonNode input = schemas.get("toaster_make-toast_input");
final JsonNode properties = input.get("properties");
assertTrue(properties.has("toasterDoneness"));
assertTrue(properties.has("toasterToastType"));
final var doc = generator.getOpenApiDocSpec(module, "http", "localhost:8181", "/", "", CONTEXT);
assertNotNull(doc);
- final var definitions = doc.getDefinitions();
- JsonNode firstContainer = definitions.get("choice-test_first-container");
+ final var schemas = doc.getComponents().getSchemas();
+ JsonNode firstContainer = schemas.get("choice-test_first-container");
assertEquals("default-value",
firstContainer.get(PROPERTIES).get("leaf-default").get("default").asText());
assertFalse(firstContainer.get(PROPERTIES).has("leaf-non-default"));
- JsonNode secondContainer = definitions.get("choice-test_second-container");
+ JsonNode secondContainer = schemas.get("choice-test_second-container");
assertTrue(secondContainer.get(PROPERTIES).has("leaf-first-case"));
assertFalse(secondContainer.get(PROPERTIES).has("leaf-second-case"));
}