This repository was archived by the owner on Mar 16, 2025. It is now read-only.
File tree 3 files changed +35
-1
lines changed
main/kotlin/io/openapiprocessor/core/parser
test/kotlin/io/openapiprocessor/core/parser 3 files changed +35
-1
lines changed Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright 2021 https://github.com/openapi-processor/openapi-processor-core
3
+ * PDX-License-Identifier: Apache-2.0
4
+ */
5
+
6
+ package io.openapiprocessor.core.parser
7
+
8
+ class NoOpenApiException : RuntimeException () {
9
+
10
+ override val message: String
11
+ get() = " can't find OpenAPI description. Is the option 'apiPath' set?"
12
+
13
+ }
Original file line number Diff line number Diff line change @@ -30,7 +30,7 @@ class Parser {
30
30
private val log: Logger = LoggerFactory .getLogger(this .javaClass.name)
31
31
32
32
fun parse (processorOptions : Map <String , * >): OpenApi {
33
- val apiPath: String = processorOptions[" apiPath" ].toString()
33
+ val apiPath: String = processorOptions[" apiPath" ]? .toString() ? : throw NoOpenApiException ()
34
34
35
35
when (val parser= processorOptions[" parser" ]?.toString()) {
36
36
ParserType .SWAGGER .name -> {
Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright 2021 https://github.com/openapi-processor/openapi-processor-core
3
+ * PDX-License-Identifier: Apache-2.0
4
+ */
5
+
6
+ package io.openapiprocessor.core.parser
7
+
8
+ import io.kotest.assertions.throwables.shouldThrow
9
+ import io.kotest.core.spec.style.StringSpec
10
+
11
+ class ParserSpec : StringSpec ({
12
+
13
+ " throws if apiPath is not set" {
14
+ val parser = Parser ()
15
+
16
+ shouldThrow<NoOpenApiException > {
17
+ parser.parse(emptyMap<String , Any >())
18
+ }
19
+ }
20
+
21
+ })
You can’t perform that action at this time.
0 commit comments