Skip to content

Commit c8f44ac

Browse files
committed
get operations is defined order
1 parent 2a8570f commit c8f44ac

3 files changed

Lines changed: 7 additions & 37 deletions

File tree

gradle/libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jacoco = "0.8.7"
1212
[libraries]
1313
openapi-processor-api = "io.openapiprocessor:openapi-processor-api:2023.1"
1414

15-
openapi-parser-bom = "io.openapiprocessor:openapi-parser-bom:2023.3"
15+
openapi-parser-bom = "io.openapiprocessor:openapi-parser-bom:2023.4-SNAPSHOT"
1616
openapi-parser-parser = { module = "io.openapiprocessor:openapi-parser" }
1717
json-schema-validator-bom = "io.openapiprocessor:json-schema-validator-bom:2023.3"
1818
json-schema-validator-validator = { module = "io.openapiprocessor:json-schema-validator" }

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

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
package io.openapiprocessor.core.parser.openapi.v30
77

88
import io.openapiparser.model.v30.PathItem
9-
import io.openapiparser.model.v30.Operation
109
import io.openapiprocessor.core.parser.HttpMethod
1110
import io.openapiprocessor.core.parser.Operation as ParserOperation
1211
import io.openapiprocessor.core.parser.Path as ParserPath
@@ -27,22 +26,8 @@ class Path(
2726
pathItem = info.refObject
2827
}
2928

30-
val result: MutableList<ParserOperation> = mutableListOf()
31-
collectNotNull(HttpMethod.GET, pathItem.get, pathItem, result)
32-
collectNotNull(HttpMethod.PUT, pathItem.put, pathItem, result)
33-
collectNotNull(HttpMethod.POST, pathItem.post, pathItem, result)
34-
collectNotNull(HttpMethod.DELETE, pathItem.delete, pathItem, result)
35-
collectNotNull(HttpMethod.OPTIONS, pathItem.options, pathItem, result)
36-
collectNotNull(HttpMethod.PATCH, pathItem.patch, pathItem, result)
37-
collectNotNull(HttpMethod.TRACE, pathItem.trace, pathItem, result)
38-
collectNotNull(HttpMethod.HEAD, pathItem.head, pathItem, result)
39-
return result
40-
}
41-
42-
private fun collectNotNull(method: HttpMethod, operation: Operation?, pathItem: PathItem, target: MutableList<ParserOperation>) {
43-
if (operation == null)
44-
return
45-
46-
target.add(Operation(method, operation, pathItem))
29+
return pathItem
30+
.operations
31+
.map { Operation(HttpMethod.valueOf(it.key.uppercase()), it.value, pathItem) }
4732
}
4833
}

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

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
package io.openapiprocessor.core.parser.openapi.v31
77

88
import io.openapiparser.model.v31.PathItem
9-
import io.openapiparser.model.v31.Operation
109
import io.openapiprocessor.core.parser.HttpMethod
1110
import io.openapiprocessor.core.parser.Operation as ParserOperation
1211
import io.openapiprocessor.core.parser.Path as ParserPath
@@ -27,22 +26,8 @@ class Path(
2726
pathItem = info.refObject
2827
}
2928

30-
val result: MutableList<ParserOperation> = mutableListOf()
31-
collectNotNull(HttpMethod.GET, pathItem.get, pathItem, result)
32-
collectNotNull(HttpMethod.PUT, pathItem.put, pathItem, result)
33-
collectNotNull(HttpMethod.POST, pathItem.post, pathItem, result)
34-
collectNotNull(HttpMethod.DELETE, pathItem.delete, pathItem, result)
35-
collectNotNull(HttpMethod.OPTIONS, pathItem.options, pathItem, result)
36-
collectNotNull(HttpMethod.PATCH, pathItem.patch, pathItem, result)
37-
collectNotNull(HttpMethod.TRACE, pathItem.trace, pathItem, result)
38-
collectNotNull(HttpMethod.HEAD, pathItem.head, pathItem, result)
39-
return result
40-
}
41-
42-
private fun collectNotNull(method: HttpMethod, operation: Operation?, pathItem: PathItem, target: MutableList<ParserOperation>) {
43-
if (operation == null)
44-
return
45-
46-
target.add(Operation(method, operation, pathItem))
29+
return pathItem
30+
.operations
31+
.map { Operation(HttpMethod.valueOf(it.key.uppercase()), it.value, pathItem) }
4732
}
4833
}

0 commit comments

Comments
 (0)