2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
20 * ECOMP is a trademark and service mark of AT&T Intellectual Property.
22 package org.onap.aai.util;
25 import java.io.IOException;
26 import java.util.Arrays;
27 import java.util.Collections;
28 import java.util.List;
29 import java.util.ListIterator;
31 import org.onap.aai.introspection.Version;
32 import org.onap.aai.util.swagger.GenerateSwagger;
34 import freemarker.template.TemplateException;
36 public class AutoGenerateHtml {
38 public static final String DEFAULT_SCHEMA_DIR = "../aai-schema";
39 //if the program is run from aai-common, use this directory as default"
40 public static final String ALT_SCHEMA_DIR = "aai-schema";
41 //used to check to see if program is run from aai-core
42 public static final String DEFAULT_RUN_DIR = "aai-core";
44 public static void main(String[] args) throws IOException, TemplateException {
45 String savedProperty = System.getProperty("aai.generate.version");
46 List<Version> versionsToGen = Arrays.asList(Version.values());
47 Collections.sort(versionsToGen);
48 Collections.reverse(versionsToGen);
49 ListIterator<Version> versionIterator = versionsToGen.listIterator();
51 if(System.getProperty("user.dir") != null && !System.getProperty("user.dir").contains(DEFAULT_RUN_DIR)) {
52 schemaDir = ALT_SCHEMA_DIR;
55 schemaDir = DEFAULT_SCHEMA_DIR;
57 while (versionIterator.hasNext()) {
58 System.setProperty("aai.generate.version", versionIterator.next().toString());
59 String yamlFile = schemaDir + "/src/main/resources/aai_swagger_yaml/aai_swagger_" + System.getProperty("aai.generate.version")+ ".yaml";
60 File swaggerYamlFile = new File(yamlFile);
61 if(swaggerYamlFile.exists()) {
62 GenerateSwagger.main(args);
65 String versionToGenerate = System.setProperty("aai.generate.version", savedProperty);