This repository was archived by the owner on Mar 16, 2025. It is now read-only.
File tree Expand file tree Collapse file tree
src/main/kotlin/io/openapiprocessor/core Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ /*
2+ * Copyright 2020 https://github.com/openapi-processor/openapi-processor-core
3+ * PDX-License-Identifier: Apache-2.0
4+ */
5+
6+ package io.openapiprocessor.core.support
7+
8+ import java.net.URI
9+ import java.nio.file.Paths
10+
11+ /* *
12+ * convert a source string to a valid URI.
13+ *
14+ * if the source is an uri string it converts it to a URI. If the source has no scheme it assumes
15+ * a local path and adds the file scheme (i.e. file:).
16+ *
17+ * @param source source path or url
18+ * @return a URI to the given source
19+ */
20+ fun toURI (source : String ): URI {
21+ try {
22+ val uri = URI (source)
23+ if (uri.scheme != null ) {
24+ return uri
25+ }
26+
27+ // no scheme, assume file path
28+ return Paths .get(source)
29+ .normalize()
30+ .toAbsolutePath()
31+ .toUri()
32+ } catch (e: Exception ) {
33+ throw e
34+ }
35+ }
Original file line number Diff line number Diff line change @@ -12,8 +12,8 @@ import io.openapiprocessor.core.model.Api
1212import io.openapiprocessor.core.model.Interface
1313import io.openapiprocessor.core.model.datatypes.InterfaceDataType
1414import io.openapiprocessor.core.model.datatypes.StringEnumDataType
15- import io.openapiprocessor.core.support.toURL
1615import io.openapiprocessor.core.model.datatypes.ModelDataType
16+ import io.openapiprocessor.core.support.toURI
1717import java.io.BufferedWriter
1818import java.io.StringWriter
1919import java.io.Writer
@@ -151,7 +151,7 @@ class ApiWriter(
151151 val root = options.targetDir
152152 val pkg = listOf (root, apiPkg).joinToString(" /" )
153153
154- val target = Paths .get (toURL(pkg). toURI())
154+ val target = Paths .get (toURI(pkg ))
155155 Files .createDirectories(target)
156156 return target
157157 }
You can’t perform that action at this time.
0 commit comments