Skip to content

Commit 9b4c60d

Browse files
committed
update api builder usage
1 parent d057ade commit 9b4c60d

File tree

3 files changed

+13
-21
lines changed

3 files changed

+13
-21
lines changed

openapi-parser/src/test/kotlin/io/openapiparser/OpenApiParserSpec.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class OpenApiParserSpec: StringSpec({
1919
""".trimIndent())
2020
.buildParser()
2121

22-
val result = parser.parse(URI(""))
22+
val result = parser.parse(URI("file:///openapi.yaml"))
2323

2424
result.version shouldBe OpenApiResult.Version.V30
2525
}
@@ -31,7 +31,7 @@ class OpenApiParserSpec: StringSpec({
3131
""".trimIndent())
3232
.buildParser()
3333

34-
val result = parser.parse(URI(""))
34+
val result = parser.parse(URI("file:///openapi.yaml"))
3535

3636
result.version shouldBe OpenApiResult.Version.V31
3737
}

openapi-parser/src/test/kotlin/io/openapiparser/OpenApiResultSpec.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ import io.openapiprocessor.jsonschema.schema.Bucket
1717
import io.openapiprocessor.jsonschema.schema.DocumentLoader
1818
import io.openapiprocessor.jsonschema.schema.DocumentStore
1919
import io.openapiprocessor.jsonschema.schema.SchemaStore
20-
import io.openapiprocessor.jsonschema.support.Uris.emptyUri
2120
import io.openapiprocessor.jsonschema.validator.Validator
21+
import java.net.URI
2222
import io.openapiparser.model.v30.OpenApi as OpenApi30
2323
import io.openapiparser.model.v31.OpenApi as OpenApi31
2424

@@ -72,7 +72,7 @@ class OpenApiResultSpec: StringSpec({
7272
""".trimIndent())
7373
.buildParser()
7474

75-
val result = parser.parse(emptyUri())
75+
val result = parser.parse(URI("file:///openapi.yaml"))
7676

7777
val schemaStore = SchemaStore(DocumentLoader(UriReader(), JacksonConverter ()))
7878
schemaStore.registerDraft4()
@@ -90,7 +90,7 @@ class OpenApiResultSpec: StringSpec({
9090
""".trimIndent())
9191
.buildParser()
9292

93-
val result = parser.parse(emptyUri())
93+
val result = parser.parse(URI("file:///openapi.yaml"))
9494

9595
val schemaStore = SchemaStore(DocumentLoader(UriReader(), JacksonConverter ()))
9696
schemaStore.registerDraft202012()

openapi-parser/src/test/kotlin/io/openapiparser/RefSpec.kt

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ class RefSpec: StringSpec({
1616

1717
"parses ref into another file" {
1818
val api = ApiBuilder()
19-
.withResource("/v30/ref-into-another-file/openapi.yaml")
20-
.buildOpenApi30()
19+
.buildOpenApi30("/v30/ref-into-another-file/openapi.yaml")
2120

2221
val schema = api.getResponseSchema("/foo", "200", "application/json")
2322
schema.ref shouldBe "foo.yaml#/Foo"
@@ -30,8 +29,7 @@ class RefSpec: StringSpec({
3029

3130
"parses ref array items with nested ref" {
3231
val api = ApiBuilder()
33-
.withResource("/v30/ref-array-items-nested/openapi.yaml")
34-
.buildOpenApi30()
32+
.buildOpenApi30("/v30/ref-array-items-nested/openapi.yaml")
3533

3634
val schema = api.getResponseSchema("/array", "200", "application/json")
3735
schema.type shouldBe "array"
@@ -54,8 +52,7 @@ class RefSpec: StringSpec({
5452

5553
"parses ref loop" {
5654
val api = ApiBuilder()
57-
.withResource("/v30/ref-loop/openapi.yaml")
58-
.buildOpenApi30()
55+
.buildOpenApi30("/v30/ref-loop/openapi.yaml")
5956

6057
val schema = api.getResponseSchema("/self-reference", "200", "application/json")
6158
schema.ref shouldBe "#/components/schemas/Self"
@@ -73,8 +70,7 @@ class RefSpec: StringSpec({
7370

7471
"parses array ref items with nested array and ref items loop" {
7572
val api = ApiBuilder()
76-
.withResource("/v30/ref-loop-array/openapi.yaml")
77-
.buildOpenApi30()
73+
.buildOpenApi30("/v30/ref-loop-array/openapi.yaml")
7874

7975
val schema = api.getResponseSchema("/response-ref", "200", "application/json")
8076

@@ -115,8 +111,7 @@ class RefSpec: StringSpec({
115111

116112
"parses ref in parameter" {
117113
val api = ApiBuilder()
118-
.withResource("/v30/ref-parameter/openapi.yaml")
119-
.buildOpenApi30()
114+
.buildOpenApi30("/v30/ref-parameter/openapi.yaml")
120115

121116
val parameters = api.getParameters("/foo")
122117
parameters.size shouldBe 1
@@ -131,8 +126,7 @@ class RefSpec: StringSpec({
131126

132127
"parses ref relative to current file" {
133128
val api = ApiBuilder()
134-
.withResource("/v30/ref-is-relative-to-current-file/openapi.yaml")
135-
.buildOpenApi30()
129+
.buildOpenApi30("/v30/ref-is-relative-to-current-file/openapi.yaml")
136130

137131
val schema = api.getResponseSchema("/foo", "200", "application/json")
138132
schema.ref shouldBe "schemas/foo.yaml#/Foo"
@@ -151,8 +145,7 @@ class RefSpec: StringSpec({
151145

152146
"parses ref into another file without pointer" {
153147
val api = ApiBuilder()
154-
.withResource("/v30/ref-into-another-file-path/openapi.yaml")
155-
.buildOpenApi30()
148+
.buildOpenApi30("/v30/ref-into-another-file-path/openapi.yaml")
156149

157150
val paths = api.paths
158151
val pathItem = paths.getPathItem("/foo")
@@ -169,8 +162,7 @@ class RefSpec: StringSpec({
169162

170163
"parses ~ escaped ref path into another file" {
171164
val api = ApiBuilder()
172-
.withResource("/v30/ref-to-escaped-path-name/openapi.yaml")
173-
.buildOpenApi30()
165+
.buildOpenApi30("/v30/ref-to-escaped-path-name/openapi.yaml")
174166

175167
val paths = api.paths
176168

0 commit comments

Comments
 (0)