diff options
author | Fiete Ostkamp <Fiete.Ostkamp@telekom.de> | 2022-12-07 13:52:46 +0000 |
---|---|---|
committer | Fiete Ostkamp <Fiete.Ostkamp@telekom.de> | 2022-12-07 15:55:11 +0000 |
commit | 1e2d336a332c3b58d07ebc6d4e9c448178281ee3 (patch) | |
tree | 8e4f3a202a7927469ac7af5800ce3ad0bfa46348 /aai-schema-gen/src/main | |
parent | 33db2e9d0c0e9da96a7507b1695cbfa2e5394489 (diff) |
Generated AAI Swagger file has schema violations
Fixes for violations
- provide a valid host (localhost) for the `host` key
- remove `example` keys for parameters
- remove `also requires` property from definitions
Other changes
- remove the license header from description and add it instead as a yaml comment (like we do it for any other file)
- remove the `contact` block since it does not contain actual contact information
- remove the reference to the AT&T wiki for the default response codes
- remove `description: n/a` values in parameters that are set when there is no description available
Issue-ID: AAI-3611
Signed-off-by: Fiete Ostkamp <Fiete.Ostkamp@telekom.de>
Change-Id: I057f7f3a49a861891c49b52bff80e5a9810f18a7
Diffstat (limited to 'aai-schema-gen/src/main')
4 files changed, 68 insertions, 47 deletions
diff --git a/aai-schema-gen/src/main/java/org/onap/aai/schemagen/GenerateXsd.java b/aai-schema-gen/src/main/java/org/onap/aai/schemagen/GenerateXsd.java index f9e7b4d..b69f036 100644 --- a/aai-schema-gen/src/main/java/org/onap/aai/schemagen/GenerateXsd.java +++ b/aai-schema-gen/src/main/java/org/onap/aai/schemagen/GenerateXsd.java @@ -189,8 +189,8 @@ public class GenerateXsd { "generating swagger yaml file requires yamlresponses_url and yamlresponses_label properties"); System.exit(1); } else { - responsesUrl = "description: " + "Response codes found in [response codes](" - + responsesLabel + ").\n"; + responsesUrl = + "description: " + "Response codes are uniform across all endpoints.\n"; } } /* diff --git a/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/NodesYAMLfromOXM.java b/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/NodesYAMLfromOXM.java index 92cc4a0..f4d15b2 100644 --- a/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/NodesYAMLfromOXM.java +++ b/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/NodesYAMLfromOXM.java @@ -92,25 +92,44 @@ public class NodesYAMLfromOXM extends OxmFileProcessor { @Override public String getDocumentHeader() { StringBuilder sb = new StringBuilder(); + sb.append("#").append(LINE_SEPARATOR).append( + "# ============LICENSE_START=======================================================") + .append(LINE_SEPARATOR).append("# org.onap.aai").append(LINE_SEPARATOR) + .append( + "# ================================================================================") + .append(LINE_SEPARATOR) + .append("# Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.") + .append(LINE_SEPARATOR) + .append( + "# ================================================================================") + .append(LINE_SEPARATOR) + .append( + "# Licensed under the Creative Commons License, Attribution 4.0 Intl. (the \"License\");") + .append(LINE_SEPARATOR) + .append("# you may not use this file except in compliance with the License.") + .append(LINE_SEPARATOR).append("# You may obtain a copy of the License at") + .append(LINE_SEPARATOR).append("# <p>").append(LINE_SEPARATOR) + .append("# https://creativecommons.org/licenses/by/4.0/").append(LINE_SEPARATOR) + .append("# <p>").append(LINE_SEPARATOR) + .append("# Unless required by applicable law or agreed to in writing, software") + .append(LINE_SEPARATOR) + .append("# distributed under the License is distributed on an \"AS IS\" BASIS,") + .append(LINE_SEPARATOR) + .append("# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.") + .append(LINE_SEPARATOR) + .append("# See the License for the specific language governing permissions and") + .append(LINE_SEPARATOR).append("# limitations under the License.") + .append(LINE_SEPARATOR) + .append( + "# ============LICENSE_END=========================================================") + .append(LINE_SEPARATOR).append("#").append(LINE_SEPARATOR).append(LINE_SEPARATOR); sb.append("swagger: \"2.0\"\ninfo:").append(LINE_SEPARATOR).append(" "); sb.append("description: |"); if (versionSupportsSwaggerDiff(v.toString())) { - sb.append("\n\n [Differences versus the previous schema version](" + "apidocs") + sb.append("\n [Differences versus the previous schema version](" + "apidocs") .append(basePath).append("/aai_swagger_").append(v.toString()).append(".diff)"); } sb.append(DOUBLE_LINE_SEPARATOR) - .append( - " Copyright © 2017-18 AT&T Intellectual Property. All rights reserved.") - .append(OxmFileProcessor.DOUBLE_LINE_SEPARATOR) - .append( - " Licensed under the Creative Commons License, Attribution 4.0 Intl. (the "License"); you may not use this documentation except in compliance with the License.") - .append(DOUBLE_LINE_SEPARATOR) - .append( - " You may obtain a copy of the License at\n\n (https://creativecommons.org/licenses/by/4.0/)") - .append(DOUBLE_LINE_SEPARATOR) - .append( - " Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.") - .append(OxmFileProcessor.DOUBLE_LINE_SEPARATOR) .append(" This document is best viewed with Firefox or Chrome. "); sb.append( "Nodes can be found by opening the models link below and finding the node-type. "); @@ -121,10 +140,7 @@ public class NodesYAMLfromOXM extends OxmFileProcessor { .append(LINE_SEPARATOR) .append(" url: http://www.apache.org/licenses/LICENSE-2.0.html") .append(LINE_SEPARATOR); - sb.append(" contact:").append(LINE_SEPARATOR).append(" name: n/a") - .append(LINE_SEPARATOR).append(" url: n/a").append(LINE_SEPARATOR) - .append(" email: n/a").append(LINE_SEPARATOR); - sb.append("host: n/a").append(LINE_SEPARATOR).append("basePath: ").append(basePath) + sb.append("host: localhost").append(LINE_SEPARATOR).append("basePath: ").append(basePath) .append("/").append(v.toString()).append(LINE_SEPARATOR); sb.append("schemes:").append(LINE_SEPARATOR).append(" - https\npaths:") .append(LINE_SEPARATOR); diff --git a/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/XSDElement.java b/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/XSDElement.java index fa00b5e..7cddc7b 100644 --- a/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/XSDElement.java +++ b/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/XSDElement.java @@ -268,8 +268,6 @@ public class XSDElement implements Element { && this.getAttribute("description").length() > 0) { sbParameter.append(" description: ").append(this.getAttribute("description")) .append("\n"); - } else { - sbParameter.append((" description: n/a\n")); } sbParameter.append((" required: false\n")); if (("java.lang.String").equals(this.getAttribute("type"))) { @@ -335,10 +333,6 @@ public class XSDElement implements Element { if (("java.lang.Boolean").equals(this.getAttribute("type"))) { sbParameter.append(" type: boolean\n"); } - if (StringUtils.isNotBlank(this.getAttribute("name"))) { - sbParameter.append(" example: " + "__") - .append(this.getAttribute("name").toUpperCase()).append("__").append("\n"); - } return sbParameter.toString(); } @@ -522,11 +516,6 @@ public class XSDElement implements Element { " *This property can be used as a filter to find the start node for a dsl query\n"); } } - String elementAlsoRequiresProperty = this.getRequiresProperty(); - if (StringUtils.isNotEmpty(elementAlsoRequiresProperty)) { - sbProperties.append(" also requires: ").append(elementAlsoRequiresProperty) - .append("\n"); - } return sbProperties.toString(); } diff --git a/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/YAMLfromOXM.java b/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/YAMLfromOXM.java index 0ded250..55767c3 100644 --- a/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/YAMLfromOXM.java +++ b/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/YAMLfromOXM.java @@ -93,25 +93,44 @@ public class YAMLfromOXM extends OxmFileProcessor { @Override public String getDocumentHeader() { StringBuilder sb = new StringBuilder(); + sb.append("#").append(LINE_SEPARATOR).append( + "# ============LICENSE_START=======================================================") + .append(LINE_SEPARATOR).append("# org.onap.aai").append(LINE_SEPARATOR) + .append( + "# ================================================================================") + .append(LINE_SEPARATOR) + .append("# Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.") + .append(LINE_SEPARATOR) + .append( + "# ================================================================================") + .append(LINE_SEPARATOR) + .append( + "# Licensed under the Creative Commons License, Attribution 4.0 Intl. (the \"License\");") + .append(LINE_SEPARATOR) + .append("# you may not use this file except in compliance with the License.") + .append(LINE_SEPARATOR).append("# You may obtain a copy of the License at") + .append(LINE_SEPARATOR).append("# <p>").append(LINE_SEPARATOR) + .append("# https://creativecommons.org/licenses/by/4.0/").append(LINE_SEPARATOR) + .append("# <p>").append(LINE_SEPARATOR) + .append("# Unless required by applicable law or agreed to in writing, software") + .append(LINE_SEPARATOR) + .append("# distributed under the License is distributed on an \"AS IS\" BASIS,") + .append(LINE_SEPARATOR) + .append("# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.") + .append(LINE_SEPARATOR) + .append("# See the License for the specific language governing permissions and") + .append(LINE_SEPARATOR).append("# limitations under the License.") + .append(LINE_SEPARATOR) + .append( + "# ============LICENSE_END=========================================================") + .append(LINE_SEPARATOR).append("#").append(LINE_SEPARATOR).append(LINE_SEPARATOR); sb.append("swagger: \"2.0\"\ninfo:").append(LINE_SEPARATOR).append(" "); sb.append("description: |"); if (versionSupportsSwaggerDiff(v.toString())) { - sb.append("\n\n [Differences versus the previous schema version](" + "apidocs" + sb.append("\n [Differences versus the previous schema version](" + "apidocs" + basePath + "/aai_swagger_" + v.toString() + ".diff)"); } sb.append(DOUBLE_LINE_SEPARATOR) - .append( - " Copyright © 2017-18 AT&T Intellectual Property. All rights reserved.") - .append(OxmFileProcessor.DOUBLE_LINE_SEPARATOR) - .append( - " Licensed under the Creative Commons License, Attribution 4.0 Intl. (the "License"); you may not use this documentation except in compliance with the License.") - .append(DOUBLE_LINE_SEPARATOR) - .append( - " You may obtain a copy of the License at\n\n (https://creativecommons.org/licenses/by/4.0/)") - .append(DOUBLE_LINE_SEPARATOR) - .append( - " Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.") - .append(OxmFileProcessor.DOUBLE_LINE_SEPARATOR) .append(" This document is best viewed with Firefox or Chrome. "); sb.append( "Nodes can be found by opening the models link below and finding the node-type. "); @@ -122,10 +141,7 @@ public class YAMLfromOXM extends OxmFileProcessor { .append( " name: Apache 2.0\n url: http://www.apache.org/licenses/LICENSE-2.0.html") .append(LINE_SEPARATOR); - sb.append(" contact:").append(LINE_SEPARATOR).append(" name: n/a") - .append(LINE_SEPARATOR).append(" url: n/a").append(LINE_SEPARATOR) - .append(" email: n/a").append(LINE_SEPARATOR); - sb.append("host: n/a").append(LINE_SEPARATOR).append("basePath: ").append(basePath) + sb.append("host: localhost").append(LINE_SEPARATOR).append("basePath: ").append(basePath) .append("/").append(v.toString()).append(LINE_SEPARATOR); sb.append("schemes:").append(LINE_SEPARATOR).append(" - https\npaths:") .append(LINE_SEPARATOR); |