From 33db2e9d0c0e9da96a7507b1695cbfa2e5394489 Mon Sep 17 00:00:00 2001 From: Fiete Ostkamp Date: Thu, 24 Nov 2022 14:29:21 +0000 Subject: [PATCH] schema-service openapi generation is ignoring types other than String, Long, Integer and Boolean Issue-ID: AAI-3607 Signed-off-by: Fiete Ostkamp Change-Id: I10a451dbe32bafec323af3f7243e38f1e40b2dce --- .../org/onap/aai/schemagen/AutoGenerateHtml.java | 50 +++++++++++----------- .../org/onap/aai/schemagen/genxsd/XSDElement.java | 30 +++++++++++++ .../resources/onap/aai_schema/aai_schema_v19.xsd | 8 ++-- .../resources/onap/aai_schema/aai_schema_v20.xsd | 6 +-- .../resources/onap/aai_schema/aai_schema_v21.xsd | 6 +-- .../resources/onap/aai_schema/aai_schema_v22.xsd | 6 +-- .../resources/onap/aai_schema/aai_schema_v23.xsd | 6 +-- .../resources/onap/aai_schema/aai_schema_v24.xsd | 6 +-- .../resources/onap/aai_schema/aai_schema_v25.xsd | 6 +-- .../resources/onap/aai_schema/aai_schema_v26.xsd | 6 +-- .../resources/onap/aai_schema/aai_schema_v27.xsd | 6 +-- 11 files changed, 83 insertions(+), 53 deletions(-) diff --git a/aai-schema-gen/src/main/java/org/onap/aai/schemagen/AutoGenerateHtml.java b/aai-schema-gen/src/main/java/org/onap/aai/schemagen/AutoGenerateHtml.java index f279aef..13fd317 100644 --- a/aai-schema-gen/src/main/java/org/onap/aai/schemagen/AutoGenerateHtml.java +++ b/aai-schema-gen/src/main/java/org/onap/aai/schemagen/AutoGenerateHtml.java @@ -22,6 +22,8 @@ package org.onap.aai.schemagen; +import freemarker.template.TemplateException; + import java.io.File; import java.io.IOException; import java.util.Collections; @@ -36,8 +38,6 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.BeansException; import org.springframework.context.annotation.AnnotationConfigApplicationContext; -import freemarker.template.TemplateException; - public class AutoGenerateHtml { private static Logger logger = LoggerFactory.getLogger(AutoGenerateHtml.class); @@ -54,31 +54,31 @@ public class AutoGenerateHtml { try (AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext( "org.onap.aai.setup", "org.onap.aai.schemagen")) { - SchemaConfigVersions schemaConfigVersions = ctx.getBean(SchemaConfigVersions.class); + SchemaConfigVersions schemaConfigVersions = ctx.getBean(SchemaConfigVersions.class); - List versionsToGen = schemaConfigVersions.getVersions(); - Collections.sort(versionsToGen); - Collections.reverse(versionsToGen); - ListIterator versionIterator = versionsToGen.listIterator(); - String schemaDir; - if (System.getProperty("user.dir") != null - && !System.getProperty("user.dir").contains(DEFAULT_RUN_DIR)) { - schemaDir = ALT_SCHEMA_DIR; - } else { - schemaDir = DEFAULT_SCHEMA_DIR; - } - String release = System.getProperty("aai.release", "onap"); - while (versionIterator.hasNext()) { - System.setProperty(AAI_GENERATE_VERSION, versionIterator.next().toString()); - String yamlFile = - schemaDir + "/src/main/resources/" + release + "/aai_swagger_yaml/aai_swagger_" - + System.getProperty(AAI_GENERATE_VERSION) + ".yaml"; - File swaggerYamlFile = new File(yamlFile); - if (swaggerYamlFile.exists()) { - GenerateSwagger.schemaConfigVersions = schemaConfigVersions; - GenerateSwagger.main(args); + List versionsToGen = schemaConfigVersions.getVersions(); + Collections.sort(versionsToGen); + Collections.reverse(versionsToGen); + ListIterator versionIterator = versionsToGen.listIterator(); + String schemaDir; + if (System.getProperty("user.dir") != null + && !System.getProperty("user.dir").contains(DEFAULT_RUN_DIR)) { + schemaDir = ALT_SCHEMA_DIR; + } else { + schemaDir = DEFAULT_SCHEMA_DIR; + } + String release = System.getProperty("aai.release", "onap"); + while (versionIterator.hasNext()) { + System.setProperty(AAI_GENERATE_VERSION, versionIterator.next().toString()); + String yamlFile = + schemaDir + "/src/main/resources/" + release + "/aai_swagger_yaml/aai_swagger_" + + System.getProperty(AAI_GENERATE_VERSION) + ".yaml"; + File swaggerYamlFile = new File(yamlFile); + if (swaggerYamlFile.exists()) { + GenerateSwagger.schemaConfigVersions = schemaConfigVersions; + GenerateSwagger.main(args); + } } - } } catch (BeansException e) { logger.warn("Unable to initialize AnnotationConfigApplicationContext ", e); } 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 205d16c..fa00b5e 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 @@ -283,6 +283,14 @@ public class XSDElement implements Element { sbParameter.append(" type: integer\n"); sbParameter.append(" format: int32\n"); } + if (("java.lang.Float").equals(this.getAttribute("type"))) { + sbParameter.append(" type: number\n"); + sbParameter.append(" format: float\n"); + } + if (("java.lang.Double").equals(this.getAttribute("type"))) { + sbParameter.append(" type: number\n"); + sbParameter.append(" format: double\n"); + } if (("java.lang.Boolean").equals(this.getAttribute("type"))) { sbParameter.append(" type: boolean\n"); } @@ -316,6 +324,14 @@ public class XSDElement implements Element { sbParameter.append(" type: integer\n"); sbParameter.append(" format: int32\n"); } + if (("java.lang.Float").equals(this.getAttribute("type"))) { + sbParameter.append(" type: number\n"); + sbParameter.append(" format: float\n"); + } + if (("java.lang.Double").equals(this.getAttribute("type"))) { + sbParameter.append(" type: number\n"); + sbParameter.append(" format: double\n"); + } if (("java.lang.Boolean").equals(this.getAttribute("type"))) { sbParameter.append(" type: boolean\n"); } @@ -351,6 +367,12 @@ public class XSDElement implements Element { if (elementType.equals("java.lang.Integer")) { sbElement.append(" type=\"xs:int\""); } + if (elementType.equals("java.lang.Float")) { + sbElement.append(" type=\"xs:float\""); + } + if (elementType.equals("java.lang.Double")) { + sbElement.append(" type=\"xs:double\""); + } if (elementType.equals("java.lang.Boolean")) { sbElement.append(" type=\"xs:boolean\""); } @@ -473,6 +495,12 @@ public class XSDElement implements Element { } else if (("java.lang.Integer").equals(this.getAttribute("type"))) { sbProperties.append("integer\n"); sbProperties.append(" format: int32\n"); + } else if (("java.lang.Float").equals(this.getAttribute("type"))) { + sbProperties.append("number\n"); + sbProperties.append(" format: float\n"); + } else if (("java.lang.Double").equals(this.getAttribute("type"))) { + sbProperties.append("number\n"); + sbProperties.append(" format: double\n"); } else if (("java.lang.Boolean").equals(this.getAttribute("type"))) { sbProperties.append("boolean\n"); } @@ -507,6 +535,8 @@ public class XSDElement implements Element { case "java.lang.String": case "java.lang.Long": case "java.lang.Integer": + case "java.lang.Float": + case "java.lang.Double": case "java.lang.Boolean": return true; } diff --git a/aai-schema/src/main/resources/onap/aai_schema/aai_schema_v19.xsd b/aai-schema/src/main/resources/onap/aai_schema/aai_schema_v19.xsd index 9999eb3..b06c0af 100644 --- a/aai-schema/src/main/resources/onap/aai_schema/aai_schema_v19.xsd +++ b/aai-schema/src/main/resources/onap/aai_schema/aai_schema_v19.xsd @@ -4073,14 +4073,14 @@ xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" - + @org.onap.aai.annotations.Metadata(description="The availability requirement for an network slice instance, expressed as a percentage.") - + @org.onap.aai.annotations.Metadata(description="The reliability requirement for an network slice instance, expressed as a percentage.") @@ -4237,14 +4237,14 @@ xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" - + @org.onap.aai.annotations.Metadata(description="The availability requirement for an network slice subnet instance, expressed as a percentage.") - + @org.onap.aai.annotations.Metadata(description="The reliability requirement for an network slice subnet instance, expressed as a percentage.") diff --git a/aai-schema/src/main/resources/onap/aai_schema/aai_schema_v20.xsd b/aai-schema/src/main/resources/onap/aai_schema/aai_schema_v20.xsd index 5f44644..7dd1d8f 100644 --- a/aai-schema/src/main/resources/onap/aai_schema/aai_schema_v20.xsd +++ b/aai-schema/src/main/resources/onap/aai_schema/aai_schema_v20.xsd @@ -4073,7 +4073,7 @@ xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" - + @org.onap.aai.annotations.Metadata(description="This parameter specifies the availability requirement, expressed as a percentage.") @@ -4258,7 +4258,7 @@ xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" - + @org.onap.aai.annotations.Metadata(description="Communication service availability target value.") @@ -7385,7 +7385,7 @@ xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" - + @org.onap.aai.annotations.Metadata(description="The reliability requirement for an network slice subnet instance, expressed as a percentage.") diff --git a/aai-schema/src/main/resources/onap/aai_schema/aai_schema_v21.xsd b/aai-schema/src/main/resources/onap/aai_schema/aai_schema_v21.xsd index 15673f7..06a62f1 100644 --- a/aai-schema/src/main/resources/onap/aai_schema/aai_schema_v21.xsd +++ b/aai-schema/src/main/resources/onap/aai_schema/aai_schema_v21.xsd @@ -4769,7 +4769,7 @@ xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" - + @org.onap.aai.annotations.Metadata(description="This parameter specifies the availability requirement, expressed as a percentage.") @@ -4954,7 +4954,7 @@ xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" - + @org.onap.aai.annotations.Metadata(description="Communication service availability target value.") @@ -8450,7 +8450,7 @@ xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" - + @org.onap.aai.annotations.Metadata(description="The reliability requirement for an network slice subnet instance, expressed as a percentage.") diff --git a/aai-schema/src/main/resources/onap/aai_schema/aai_schema_v22.xsd b/aai-schema/src/main/resources/onap/aai_schema/aai_schema_v22.xsd index 9856248..9a9d3d3 100644 --- a/aai-schema/src/main/resources/onap/aai_schema/aai_schema_v22.xsd +++ b/aai-schema/src/main/resources/onap/aai_schema/aai_schema_v22.xsd @@ -6301,7 +6301,7 @@ xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" - + @org.onap.aai.annotations.Metadata(description="This parameter specifies the availability requirement, expressed as a percentage.") @@ -6507,7 +6507,7 @@ xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" - + @org.onap.aai.annotations.Metadata(description="Communication service availability target value.") @@ -10963,7 +10963,7 @@ xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" - + @org.onap.aai.annotations.Metadata(description="The reliability requirement for an network slice subnet instance, expressed as a percentage.") diff --git a/aai-schema/src/main/resources/onap/aai_schema/aai_schema_v23.xsd b/aai-schema/src/main/resources/onap/aai_schema/aai_schema_v23.xsd index d3bd4f0..6671cde 100644 --- a/aai-schema/src/main/resources/onap/aai_schema/aai_schema_v23.xsd +++ b/aai-schema/src/main/resources/onap/aai_schema/aai_schema_v23.xsd @@ -6301,7 +6301,7 @@ xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" - + @org.onap.aai.annotations.Metadata(description="This parameter specifies the availability requirement, expressed as a percentage.") @@ -6507,7 +6507,7 @@ xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" - + @org.onap.aai.annotations.Metadata(description="Communication service availability target value.") @@ -11012,7 +11012,7 @@ xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" - + @org.onap.aai.annotations.Metadata(description="The reliability requirement for an network slice subnet instance, expressed as a percentage.") diff --git a/aai-schema/src/main/resources/onap/aai_schema/aai_schema_v24.xsd b/aai-schema/src/main/resources/onap/aai_schema/aai_schema_v24.xsd index 568ec37..f616f88 100644 --- a/aai-schema/src/main/resources/onap/aai_schema/aai_schema_v24.xsd +++ b/aai-schema/src/main/resources/onap/aai_schema/aai_schema_v24.xsd @@ -7199,7 +7199,7 @@ xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" - + @org.onap.aai.annotations.Metadata(description="This parameter specifies the availability requirement, expressed as a percentage.") @@ -7405,7 +7405,7 @@ xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" - + @org.onap.aai.annotations.Metadata(description="Communication service availability target value.") @@ -11911,7 +11911,7 @@ xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" - + @org.onap.aai.annotations.Metadata(description="The reliability requirement for an network slice subnet instance, expressed as a percentage.") diff --git a/aai-schema/src/main/resources/onap/aai_schema/aai_schema_v25.xsd b/aai-schema/src/main/resources/onap/aai_schema/aai_schema_v25.xsd index 87faf90..8b3958a 100644 --- a/aai-schema/src/main/resources/onap/aai_schema/aai_schema_v25.xsd +++ b/aai-schema/src/main/resources/onap/aai_schema/aai_schema_v25.xsd @@ -7248,7 +7248,7 @@ xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" - + @org.onap.aai.annotations.Metadata(description="This parameter specifies the availability requirement, expressed as a percentage.") @@ -7454,7 +7454,7 @@ xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" - + @org.onap.aai.annotations.Metadata(description="Communication service availability target value.") @@ -11960,7 +11960,7 @@ xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" - + @org.onap.aai.annotations.Metadata(description="The reliability requirement for an network slice subnet instance, expressed as a percentage.") diff --git a/aai-schema/src/main/resources/onap/aai_schema/aai_schema_v26.xsd b/aai-schema/src/main/resources/onap/aai_schema/aai_schema_v26.xsd index ca0a70f..56a0ef9 100644 --- a/aai-schema/src/main/resources/onap/aai_schema/aai_schema_v26.xsd +++ b/aai-schema/src/main/resources/onap/aai_schema/aai_schema_v26.xsd @@ -7248,7 +7248,7 @@ xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" - + @org.onap.aai.annotations.Metadata(description="This parameter specifies the availability requirement, expressed as a percentage.") @@ -7454,7 +7454,7 @@ xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" - + @org.onap.aai.annotations.Metadata(description="Communication service availability target value.") @@ -11981,7 +11981,7 @@ xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" - + @org.onap.aai.annotations.Metadata(description="The reliability requirement for an network slice subnet instance, expressed as a percentage.") diff --git a/aai-schema/src/main/resources/onap/aai_schema/aai_schema_v27.xsd b/aai-schema/src/main/resources/onap/aai_schema/aai_schema_v27.xsd index 3efe1d9..075dcb9 100644 --- a/aai-schema/src/main/resources/onap/aai_schema/aai_schema_v27.xsd +++ b/aai-schema/src/main/resources/onap/aai_schema/aai_schema_v27.xsd @@ -7269,7 +7269,7 @@ xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" - + @org.onap.aai.annotations.Metadata(description="This parameter specifies the availability requirement, expressed as a percentage.") @@ -7475,7 +7475,7 @@ xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" - + @org.onap.aai.annotations.Metadata(description="Communication service availability target value.") @@ -12009,7 +12009,7 @@ xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" - + @org.onap.aai.annotations.Metadata(description="The reliability requirement for an network slice subnet instance, expressed as a percentage.") -- 2.16.6