Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
cjbooms committed Jul 17, 2023
1 parent 7d99ff7 commit d9d52ff
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions src/main/kotlin/com/cjbooms/fabrikt/model/SourceApi.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ data class SchemaInfo(val name: String, val schema: Schema) {

data class SourceApi(
private val rawApiSpec: String,
val baseDir: Path = Paths.get("").toAbsolutePath()
val baseDir: Path = Paths.get("").toAbsolutePath(),
) {
companion object {
private val logger = Logger.getGlobal()

fun create(
baseApi: String,
apiFragments: Collection<String>,
baseDir: Path = Paths.get("").toAbsolutePath()
baseDir: Path = Paths.get("").toAbsolutePath(),
): SourceApi {
val combinedApi =
apiFragments.fold(baseApi) { acc: String, fragment -> YamlUtils.mergeYamlTrees(acc, fragment) }
Expand All @@ -50,21 +50,23 @@ data class SourceApi(
val name = entry.key
val schema = entry.value
if (schema.type == OasType.Object.type && (
schema.oneOfSchemas?.isNotEmpty() == true ||
schema.allOfSchemas?.isNotEmpty() == true ||
schema.anyOfSchemas?.isNotEmpty() == true
)
)
schema.oneOfSchemas?.isNotEmpty() == true ||
schema.allOfSchemas?.isNotEmpty() == true ||
schema.anyOfSchemas?.isNotEmpty() == true
)
) {
errors + listOf(
ValidationError(
"'$name' schema contains an invalid combination of properties and `oneOf | anyOf | allOf`. " +
"Do not use properties and a combiner at the same level."
)
"Do not use properties and a combiner at the same level.",
),
)
else if (schema.type == null && schema.properties?.isNotEmpty() == true) {
} else if (schema.type == null && schema.properties?.isNotEmpty() == true) {
logger.warning("Schema '$name' has 'type: null' but defines properties. Assuming: 'type: object'")
errors
} else errors
} else {
errors
}
}

return api.schemas.map { it.value.properties }.flatMap { it.entries }
Expand Down

0 comments on commit d9d52ff

Please sign in to comment.