Skip to content

Commit

Permalink
chore: Sorting OpenAPI output (#2854)
Browse files Browse the repository at this point in the history
  • Loading branch information
StaNov authored Jan 17, 2025
1 parent f26d092 commit 9f67ac8
Show file tree
Hide file tree
Showing 2 changed files with 6,141 additions and 6,598 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,27 @@ class OpenApiGroupBuilder(

cleanUnusedModels()

sortOutput()

return@lazy builder.build()
}

private fun sortOutput() {
builder.addOpenApiCustomizer { openAPI ->
openAPI.paths =
Paths().apply {
openAPI.paths.toSortedMap().forEach { (key, value) ->
addPathItem(key, value)
value.parameters?.sortBy { it.name }
}
}
openAPI.components.schemas = openAPI.components.schemas.toSortedMap()
openAPI.components.schemas.forEach { (_, value) ->
value.properties = value.properties?.toSortedMap()
}
}
}

private fun cleanUnusedModels() {
builder.addOpenApiCustomizer {
OpenApiUnusedSchemaCleaner(it).clean()
Expand Down
Loading

0 comments on commit 9f67ac8

Please sign in to comment.