--- /dev/null
+/*
+ * Copyright (c) 2024 PANTHEON.tech, s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.restconf.openapi.impl;
+
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+
+/**
+ * Test for <a href="https://lf-opendaylight.atlassian.net/browse/NETCONF-1389">NETCONF-1389</a>.
+ */
+class NC1389Test extends AbstractDocumentTest {
+
+ @BeforeAll
+ static void beforeAll() {
+ initializeClass("/nc1389/yang/");
+ }
+
+ /**
+ * Tests the swagger document generated for the leafref-test@2024-09-11.yang model.
+ */
+ @Test
+ void getDocByModuleTest() throws Exception {
+ final var expectedJson = getExpectedDoc("nc1389/document/leafref-test.json");
+ final var moduleDoc = getDocByModule("leafref-test", "2024-09-11");
+ JSONAssert.assertEquals(expectedJson, moduleDoc, IGNORE_ORDER);
+ }
+}
--- /dev/null
+{
+ "openapi" : "3.0.3",
+ "info" : {
+ "version" : "1.0.0",
+ "title" : "leafref-test",
+ "description" : "We are providing full API for configurational data which can be edited (by POST, PUT, PATCH and DELETE).\nFor operational data we only provide GET API.\n\nFor majority of request you can see only config data in examples. That's because we can show only one example\nper request. The exception when you can see operational data in example is when data are representing\noperational (config false) container with no config data in it."
+ },
+ "servers" : [ {
+ "url" : "http://localhost:8181/"
+ } ],
+ "paths" : {
+ "/rests/data" : {
+ "post" : {
+ "description" : "\n\nNote:\nIn example payload, you can see only the first data node child of the resource to be created, following the\nguidelines of RFC 8040, which allows us to create only one resource in POST request.\n",
+ "summary" : "POST - Controller - leafref-test - leafref-test",
+ "requestBody" : {
+ "description" : "cntr",
+ "content" : {
+ "application/json" : {
+ "schema" : {
+ "properties" : {
+ "cntr" : {
+ "$ref" : "#/components/schemas/leafref-test_cntr",
+ "type" : "object"
+ }
+ }
+ }
+ },
+ "application/xml" : {
+ "schema" : {
+ "$ref" : "#/components/schemas/leafref-test_cntr"
+ }
+ }
+ }
+ },
+ "responses" : {
+ "201" : {
+ "description" : "Created"
+ }
+ },
+ "tags" : [ "Controller leafref-test" ],
+ "parameters" : [ ]
+ }
+ },
+ "/rests/data/leafref-test:cntr" : {
+ "post" : {
+ "description" : "\n\nNote:\nIn example payload, you can see only the first data node child of the resource to be created, following the\nguidelines of RFC 8040, which allows us to create only one resource in POST request.\n",
+ "summary" : "POST - Controller - leafref-test - cntr",
+ "requestBody" : {
+ "description" : "lst",
+ "content" : {
+ "application/json" : {
+ "schema" : {
+ "properties" : {
+ "lst" : {
+ "type" : "array",
+ "items" : {
+ "$ref" : "#/components/schemas/leafref-test_cntr_lst",
+ "type" : "object"
+ }
+ }
+ }
+ }
+ },
+ "application/xml" : {
+ "schema" : {
+ "$ref" : "#/components/schemas/leafref-test_cntr_lst"
+ }
+ }
+ }
+ },
+ "responses" : {
+ "201" : {
+ "description" : "Created"
+ }
+ },
+ "tags" : [ "Controller leafref-test" ],
+ "parameters" : [ ]
+ },
+ "put" : {
+ "description" : "",
+ "summary" : "PUT - leafref-test - Controller - cntr",
+ "requestBody" : {
+ "description" : "cntr",
+ "content" : {
+ "application/json" : {
+ "schema" : {
+ "properties" : {
+ "leafref-test:cntr" : {
+ "$ref" : "#/components/schemas/leafref-test_cntr",
+ "type" : "object"
+ }
+ }
+ }
+ },
+ "application/xml" : {
+ "schema" : {
+ "$ref" : "#/components/schemas/leafref-test_cntr"
+ }
+ }
+ }
+ },
+ "responses" : {
+ "201" : {
+ "description" : "Created"
+ },
+ "204" : {
+ "description" : "Updated"
+ }
+ },
+ "tags" : [ "Controller leafref-test" ],
+ "parameters" : [ ]
+ },
+ "patch" : {
+ "description" : "",
+ "summary" : "PATCH - leafref-test - Controller - cntr",
+ "requestBody" : {
+ "description" : "cntr",
+ "content" : {
+ "application/yang-data+json" : {
+ "schema" : {
+ "properties" : {
+ "leafref-test:cntr" : {
+ "$ref" : "#/components/schemas/leafref-test_cntr",
+ "type" : "object"
+ }
+ }
+ }
+ },
+ "application/yang-data+xml" : {
+ "schema" : {
+ "$ref" : "#/components/schemas/leafref-test_cntr"
+ }
+ }
+ }
+ },
+ "responses" : {
+ "200" : {
+ "description" : "OK"
+ },
+ "204" : {
+ "description" : "Updated"
+ }
+ },
+ "tags" : [ "Controller leafref-test" ],
+ "parameters" : [ ]
+ },
+ "delete" : {
+ "description" : "",
+ "summary" : "DELETE - Controller - leafref-test - cntr",
+ "responses" : {
+ "204" : {
+ "description" : "Deleted"
+ }
+ },
+ "tags" : [ "Controller leafref-test" ],
+ "parameters" : [ ]
+ },
+ "get" : {
+ "description" : "",
+ "summary" : "GET - Controller - leafref-test - cntr",
+ "responses" : {
+ "200" : {
+ "description" : "200",
+ "content" : {
+ "application/xml" : {
+ "schema" : {
+ "$ref" : "#/components/schemas/leafref-test_cntr"
+ }
+ },
+ "application/json" : {
+ "schema" : {
+ "properties" : {
+ "cntr" : {
+ "$ref" : "#/components/schemas/leafref-test_cntr",
+ "type" : "object"
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ "tags" : [ "Controller leafref-test" ],
+ "parameters" : [ {
+ "name" : "content",
+ "in" : "query",
+ "required" : false,
+ "schema" : {
+ "enum" : [ "config", "nonconfig", "all" ],
+ "type" : "string"
+ }
+ } ]
+ }
+ },
+ "/rests/data/leafref-test:cntr/lst={lf2}" : {
+ "put" : {
+ "description" : "",
+ "summary" : "PUT - leafref-test - Controller - lst",
+ "requestBody" : {
+ "description" : "lst",
+ "content" : {
+ "application/json" : {
+ "schema" : {
+ "properties" : {
+ "leafref-test:lst" : {
+ "type" : "array",
+ "items" : {
+ "$ref" : "#/components/schemas/leafref-test_cntr_lst",
+ "type" : "object"
+ }
+ }
+ }
+ }
+ },
+ "application/xml" : {
+ "schema" : {
+ "$ref" : "#/components/schemas/leafref-test_cntr_lst"
+ }
+ }
+ }
+ },
+ "responses" : {
+ "201" : {
+ "description" : "Created"
+ },
+ "204" : {
+ "description" : "Updated"
+ }
+ },
+ "tags" : [ "Controller leafref-test" ],
+ "parameters" : [ {
+ "name" : "lf2",
+ "in" : "path",
+ "required" : true,
+ "schema" : {
+ "type" : "string"
+ }
+ } ]
+ },
+ "patch" : {
+ "description" : "",
+ "summary" : "PATCH - leafref-test - Controller - lst",
+ "requestBody" : {
+ "description" : "lst",
+ "content" : {
+ "application/yang-data+json" : {
+ "schema" : {
+ "properties" : {
+ "leafref-test:lst" : {
+ "type" : "array",
+ "items" : {
+ "$ref" : "#/components/schemas/leafref-test_cntr_lst",
+ "type" : "object"
+ }
+ }
+ }
+ }
+ },
+ "application/yang-data+xml" : {
+ "schema" : {
+ "$ref" : "#/components/schemas/leafref-test_cntr_lst"
+ }
+ }
+ }
+ },
+ "responses" : {
+ "200" : {
+ "description" : "OK"
+ },
+ "204" : {
+ "description" : "Updated"
+ }
+ },
+ "tags" : [ "Controller leafref-test" ],
+ "parameters" : [ {
+ "name" : "lf2",
+ "in" : "path",
+ "required" : true,
+ "schema" : {
+ "type" : "string"
+ }
+ } ]
+ },
+ "delete" : {
+ "description" : "",
+ "summary" : "DELETE - Controller - leafref-test - lst",
+ "responses" : {
+ "204" : {
+ "description" : "Deleted"
+ }
+ },
+ "tags" : [ "Controller leafref-test" ],
+ "parameters" : [ {
+ "name" : "lf2",
+ "in" : "path",
+ "required" : true,
+ "schema" : {
+ "type" : "string"
+ }
+ } ]
+ },
+ "get" : {
+ "description" : "",
+ "summary" : "GET - Controller - leafref-test - lst",
+ "responses" : {
+ "200" : {
+ "description" : "200",
+ "content" : {
+ "application/xml" : {
+ "schema" : {
+ "$ref" : "#/components/schemas/leafref-test_cntr_lst"
+ }
+ },
+ "application/json" : {
+ "schema" : {
+ "properties" : {
+ "lst" : {
+ "type" : "array",
+ "items" : {
+ "$ref" : "#/components/schemas/leafref-test_cntr_lst",
+ "type" : "object"
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ "tags" : [ "Controller leafref-test" ],
+ "parameters" : [ {
+ "name" : "lf2",
+ "in" : "path",
+ "required" : true,
+ "schema" : {
+ "type" : "string"
+ }
+ }, {
+ "name" : "content",
+ "in" : "query",
+ "required" : false,
+ "schema" : {
+ "enum" : [ "config", "nonconfig", "all" ],
+ "type" : "string"
+ }
+ } ]
+ }
+ }
+ },
+ "components" : {
+ "schemas" : {
+ "leafref-test_cntr" : {
+ "title" : "leafref-test_cntr",
+ "type" : "object",
+ "properties" : {
+ "lf1" : {
+ "description" : "",
+ "type" : "string",
+ "example" : "Some lf1"
+ },
+ "lst" : {
+ "type" : "array",
+ "items" : {
+ "$ref" : "#/components/schemas/leafref-test_cntr_lst"
+ },
+ "description" : "",
+ "example" : [ {
+ "lf2" : "Some lf2"
+ } ],
+ "minItems" : 1
+ }
+ },
+ "required" : [ "lst" ],
+ "xml" : {
+ "name" : "cntr",
+ "namespace" : "urn:leafref-test"
+ }
+ },
+ "leafref-test_cntr_lst" : {
+ "title" : "leafref-test_cntr_lst",
+ "type" : "object",
+ "properties" : {
+ "lf2" : {
+ "description" : "",
+ "type" : "string",
+ "example" : "Some lf2"
+ }
+ },
+ "xml" : {
+ "name" : "lst",
+ "namespace" : "urn:leafref-test"
+ }
+ }
+ },
+ "securitySchemes" : {
+ "basicAuth" : {
+ "scheme" : "basic",
+ "type" : "http"
+ }
+ }
+ },
+ "security" : [ {
+ "basicAuth" : [ ]
+ } ]
+}