diff --git a/src/main/java/gov/usgs/earthquake/nshmp/netcdf/swagger/UpdateSwagger.java b/src/main/java/gov/usgs/earthquake/nshmp/netcdf/swagger/UpdateSwagger.java index 63cec2ffdbb38596e8adc678b46b5ef7b03926d9..9f70441a2e2b89bab4c85ffe6a1dad919b0caec6 100644 --- a/src/main/java/gov/usgs/earthquake/nshmp/netcdf/swagger/UpdateSwagger.java +++ b/src/main/java/gov/usgs/earthquake/nshmp/netcdf/swagger/UpdateSwagger.java @@ -1,38 +1,40 @@ package gov.usgs.earthquake.nshmp.netcdf.swagger; +import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; -import java.net.URISyntaxException; -import java.net.URL; import java.nio.file.Path; import java.nio.file.Paths; import java.util.Map; +import java.util.Properties; import org.yaml.snakeyaml.DumperOptions; import org.yaml.snakeyaml.Yaml; -import com.google.common.io.Resources; - import gov.usgs.earthquake.nshmp.netcdf.NshmGroup; import io.swagger.v3.oas.models.PathItem; /** * Create Swagger files for each model and update context path. + * + * @author U.S. Geological Survey */ class UpdateSwagger { - private static final URL SWAGGER_URL = Resources.getResource("swagger"); private static final Path SWAGGER_DIR = Paths.get("swagger-files"); private static final Path TARGET_FILE; + private static final String OPENAPI_TARGET = "micronaut.openapi.target.file"; static { - try { - var dir = Paths.get(SWAGGER_URL.toURI()); - TARGET_FILE = dir.resolve("netcdf-swagger.yml"); - } catch (URISyntaxException e) { + try (var file = new FileInputStream("openapi.properties")) { + var properties = new Properties(); + properties.load(file); + var openapi = properties.getProperty(OPENAPI_TARGET); + TARGET_FILE = Paths.get(openapi); + } catch (Exception e) { throw new RuntimeException(e); } }