Skip to content

Commit a126aa9

Browse files
committed
get document uri (#115)
1 parent 412dabe commit a126aa9

File tree

10 files changed

+40
-1
lines changed

10 files changed

+40
-1
lines changed

gradle/libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[versions]
22
processor = "2025.3-SNAPSHOT"
3-
parser = "2025.2"
3+
parser = "2025.3-SNAPSHOT"
44
api = "2024.2"
55

66
kotlin = "2.1.20"

openapi-processor-core-parser-api/src/main/kotlin/io/openapiprocessor/core/parser/Schema.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
package io.openapiprocessor.core.parser
77

8+
import java.net.URI
9+
810
/**
911
* OpenAPI Schema abstraction.
1012
*/
@@ -65,4 +67,6 @@ interface Schema {
6567
val extensions: Map<String, *>
6668

6769
val title: String?
70+
71+
val documentUri: URI
6872
}

openapi-processor-core-parser-openapi4j/src/main/kotlin/io/openapiprocessor/core/parser/openapi4j/Schema.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
package io.openapiprocessor.core.parser.openapi4j
77

8+
import java.net.URI
89
import io.openapiprocessor.core.parser.Schema as ParserSchema
910
import org.openapi4j.parser.model.v3.Schema as O4jSchema
1011

@@ -128,4 +129,7 @@ class Schema(val schema: O4jSchema) : ParserSchema {
128129

129130
override val title: String?
130131
get() = schema.title
132+
133+
override val documentUri: URI
134+
get() = TODO("deriving the package name from the document location is not supported with the openapi4j parser.")
131135
}

openapi-processor-core-parser-swagger/src/main/kotlin/io/openapiprocessor/core/parser/swagger/Schema.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
package io.openapiprocessor.core.parser.swagger
77

88
import io.swagger.v3.oas.models.SpecVersion
9+
import java.net.URI
910
import io.openapiprocessor.core.parser.Schema as ParserSchema
1011
import io.swagger.v3.oas.models.media.ComposedSchema as SwaggerComposedSchema
1112
import io.swagger.v3.oas.models.media.Schema as SwaggerSchema
@@ -153,4 +154,7 @@ class Schema(private val schema: SwaggerSchema<*>): ParserSchema {
153154

154155
override val title: String?
155156
get() = schema.title
157+
158+
override val documentUri: URI
159+
get() = TODO("deriving the package name from the document location is not supported with the swagger parser.")
156160
}

openapi-processor-core/src/main/kotlin/io/openapiprocessor/core/converter/SchemaInfo.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import io.openapiprocessor.core.model.datatypes.DataTypeConstraints
1010
import io.openapiprocessor.core.parser.HttpMethod
1111
import io.openapiprocessor.core.parser.Schema
1212
import io.openapiprocessor.core.support.capitalizeFirstChar
13+
import java.net.URI
1314
import io.openapiprocessor.core.parser.RefResolver as ParserRefResolver
1415

1516
/**
@@ -444,4 +445,8 @@ open class SchemaInfo(
444445
private fun getNestedTypeName(nestedName: String): String {
445446
return name + nestedName.capitalizeFirstChar()
446447
}
448+
449+
fun getDocumentUri(): URI {
450+
return schema.documentUri
451+
}
447452
}

openapi-processor-core/src/main/kotlin/io/openapiprocessor/core/parser/NullSchema.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
package io.openapiprocessor.core.parser
77

8+
import java.net.URI
9+
810
object NullSchema: Schema {
911

1012
override fun getType(): String? {
@@ -108,4 +110,7 @@ object NullSchema: Schema {
108110

109111
override val title: String?
110112
get() = null
113+
114+
override val documentUri: URI
115+
get() = URI.create("should/not/be/called")
111116
}

openapi-processor-core/src/main/kotlin/io/openapiprocessor/core/parser/openapi/v30/Schema.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
package io.openapiprocessor.core.parser.openapi.v30
77

8+
import java.net.URI
89
import io.openapiparser.model.v30.Schema as Schema30
910
import io.openapiprocessor.core.parser.Schema as ParserSchema
1011

@@ -157,4 +158,7 @@ class Schema(val schema: Schema30) : ParserSchema {
157158

158159
override val title: String?
159160
get() = schema.title
161+
162+
override val documentUri: URI
163+
get() = schema.documentUri
160164
}

openapi-processor-core/src/main/kotlin/io/openapiprocessor/core/parser/openapi/v31/Schema.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
package io.openapiprocessor.core.parser.openapi.v31
77

8+
import java.net.URI
89
import io.openapiparser.model.v31.Schema as Schema31
910
import io.openapiprocessor.core.parser.Schema as ParserSchema
1011

@@ -159,4 +160,7 @@ class Schema(val schema: Schema31) : ParserSchema {
159160

160161
override val title: String?
161162
get() = schema.title
163+
164+
override val documentUri: URI
165+
get() = schema.documentUri
162166
}

openapi-processor-core/src/test/groovy/io/openapiprocessor/core/writer/java/TestSchema.groovy

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,4 +83,9 @@ class TestSchema implements Schema {
8383
String getTitle() {
8484
return null
8585
}
86+
87+
@Override
88+
URI getDocumentUri() {
89+
return URI.create("null")
90+
}
8691
}

openapi-processor-core/src/test/kotlin/io/openapiprocessor/core/support/Schema.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
package io.openapiprocessor.core.support
77

88
import io.openapiprocessor.core.parser.Schema
9+
import java.net.URI
910
import io.openapiprocessor.core.parser.Schema as ParserSchema
1011

1112
/**
@@ -117,4 +118,7 @@ class Schema(
117118

118119
override val title: String?
119120
get() = TODO("Not yet implemented")
121+
122+
override val documentUri: URI
123+
get() = TODO("Not yet implemented")
120124
}

0 commit comments

Comments
 (0)