@@ -106,59 +106,18 @@ public boolean generateKING() throws Exception {
106106 transformer .setXslParm ("json-version" ,"3.0" );
107107 succeeds = succeeds && transformer .transformStep ("properties/ROUGH_OPENAPI_ENDPRODUCT_XML_FILE_PATH" ,"properties/RESULT_OPENAPI_ENDPRODUCT_XML_FILE_PATH" , "properties/IMVERTOR_METAMODEL_KINGBSM_OPENAPI_ENDPRODUCT_XML_XSLPATH" );
108108
109- succeeds = succeeds && transformer .transformStep ("properties/RESULT_OPENAPI_ENDPRODUCT_XML_FILE_PATH" ,"properties/RESULT_YAMLHEADER_FILE_PATH" , "properties/IMVERTOR_METAMODEL_KING_YAMLHEADER_XSLPATH" );
110- succeeds = succeeds && transformer .transformStep ("properties/RESULT_OPENAPI_ENDPRODUCT_XML_FILE_PATH" ,"properties/RESULT_YAMLBODY_FILE_PATH" , "properties/IMVERTOR_METAMODEL_KING_YAMLBODY_XSLPATH" );
111-
112- // Next 2 lines are for generating json and yaml using saxon
109+ // Next 2 lines are for generating json and yaml using a json mapping file
113110 succeeds = succeeds && transformer .transformStep ("properties/RESULT_OPENAPI_ENDPRODUCT_XML_FILE_PATH" ,"properties/RESULT_JSONMAPPING_4_BODY_FILE_PATH" , "properties/IMVERTOR_METAMODEL_KING_EP4JSONMAPPING_4BODY_XSLPATH" );
114111 succeeds = succeeds && transformer .transformStep ("properties/RESULT_OPENAPI_ENDPRODUCT_XML_FILE_PATH" ,"properties/RESULT_JSONMAPPING_4_HEADER_FILE_PATH" ,"properties/IMVERTOR_METAMODEL_KING_EP4JSONMAPPING_4HEADER_XSLPATH" );
115112
116113 transformer .setXslParm ("json-version" ,"2.0" );
117- succeeds = succeeds && transformer .transformStep ("properties/RESULT_OPENAPI_ENDPRODUCT_XML_FILE_PATH" ,"properties/RESULT_YAMLBODY_FILE_PATH2" , "properties/IMVERTOR_METAMODEL_KING_YAMLBODY_XSLPATH" );
118114
119- // Next line is for generating json using saxon
115+ // Next line is for generating json using a json mapping file
120116 succeeds = succeeds && transformer .transformStep ("properties/RESULT_OPENAPI_ENDPRODUCT_XML_FILE_PATH" ,"properties/RESULT_JSONMAPPING_4_BODY_FILE_PATH2" , "properties/IMVERTOR_METAMODEL_KING_EP4JSONMAPPING_4BODY_XSLPATH" );
121117
122- if (succeeds ) {
123- // concatenate
124- YamlFile headerFile = new YamlFile (configurator .getXParm ("properties/RESULT_YAMLHEADER_FILE_PATH" ));
125- JsonFile bodyFile = new JsonFile (configurator .getXParm ("properties/RESULT_YAMLBODY_FILE_PATH" ));
126- //bodyFile.prettyPrint();
127- YamlFile yamlFile = new YamlFile (configurator .getXParm ("properties/RESULT_YAML_FILE_PATH2" ));
128- JsonFile bodyFile2 = new JsonFile (configurator .getXParm ("properties/RESULT_YAMLBODY_FILE_PATH2" ));
129- //bodyFile2.prettyPrint();
130-
131- // validate
132- String hc = headerFile .getContent ();
133- succeeds = succeeds && YamlFile .validate (hc );
134- succeeds = succeeds && bodyFile .toYaml (yamlFile );
135- String bc = yamlFile .getContent ();
136-
137- // in all cases copy results to app folder
138- yamlFile .setContent (hc + "\n " + bc );
139-
140- // convert for debug purposes the Yaml file generated in line 111 to a Json-mapping file.
141- JsonFile headerJSONFile = new JsonFile (configurator .getXParm ("properties/RESULT_YAML_4_HEADER_FILE_PATH2" ));
142- XmlFile jsonXmlMappingFile4header = new XmlFile (configurator .getXParm ("properties/RESULT_JSONMAPPING_4_JSONHEADER_FILE_PATH" ));
143-
144- headerFile .toJson (headerJSONFile );
145- headerJSONFile .toXml (jsonXmlMappingFile4header );
146-
147- //String schemaName = configurator.getXParm("appinfo/OpenAPI-schema-name");
148-
149- // copy to the app folder
150- AnyFile appYamlFile = new AnyFile (yamlFolder ,"openapi.yaml" );
151- AnyFile appJsonFile = new AnyFile (yamlFolder ,"openapi.json" );
152- AnyFile appJson2File = new AnyFile (yamlFolder ,"openapi_draft04.json" );
153- yamlFile .copyFile (appYamlFile );
154- bodyFile .copyFile (appJsonFile );
155- bodyFile2 .copyFile (appJson2File );
156- }
157- // pretty print and store to json folder
118+ // This is the code for generating yaml and json schema's
158119 if (succeeds ) {
159120
160- AnyFolder appFolder = new AnyFolder (configurator .getXParm ("system/work-app-folder-path" ));
161-
162121 // convert the json xml to Json without schema reference and than to yaml.
163122 XmlFile xmlMappingFileBody = new XmlFile (configurator .getXParm ("properties/RESULT_JSONMAPPING_4_BODY_FILE_PATH" ));
164123 JsonFile jsonFileBody = new JsonFile (configurator .getXParm ("properties/RESULT_JSON_4_BODY_FILE_PATH" ));
@@ -182,12 +141,6 @@ public boolean generateKING() throws Exception {
182141 xmlMappingFileHeader .toJson (jsonFileHeader );
183142 jsonFileHeader .toYaml (yamlFileHeader );
184143
185- // convert for debug purposes the Json file generated in line 112 to a Json-mapping file.
186- JsonFile jsonbodyFile = new JsonFile (configurator .getXParm ("properties/RESULT_YAMLBODY_FILE_PATH" ));
187- XmlFile xmlMappingFileBody3 = new XmlFile (configurator .getXParm ("properties/RESULT_JSONMAPPING_4_BODY_FILE_PATH3" ));
188-
189- jsonbodyFile .toXml (xmlMappingFileBody3 );
190-
191144 // validate
192145 String hc = yamlFileHeader .getContent ();
193146 String bc = yamlFileBody .getContent ();
@@ -197,12 +150,10 @@ public boolean generateKING() throws Exception {
197150 // concatenate the yamlbody to the yamlheader
198151 yamlFile .setContent (hc + "\n " + bc );
199152
200- //String schemaName = configurator.getXParm("appinfo/OpenAPI-schema-name");
201-
202153 // copy to the imvert folder !!! Must be changed to the app folder in future
203- AnyFile appYamlFile = new AnyFile (appFolder ,"openapi-test .yaml" );
204- AnyFile appJsonFile = new AnyFile (appFolder ,"openapi-test .json" );
205- AnyFile appJson2File = new AnyFile (appFolder ,"openapi_draft04-test .json" );
154+ AnyFile appYamlFile = new AnyFile (yamlFolder ,"openapi.yaml" );
155+ AnyFile appJsonFile = new AnyFile (yamlFolder ,"openapi.json" );
156+ AnyFile appJson2File = new AnyFile (yamlFolder ,"openapi_draft04.json" );
206157 yamlFile .copyFile (appYamlFile );
207158 jsonFileBody .copyFile (appJsonFile );
208159 jsonFileBody2 .copyFile (appJson2File );
0 commit comments