Skip to content

Commit

Permalink
Disable Plugin from coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
nomisRev committed Jul 10, 2024
1 parent 3742f09 commit e10d8af
Show file tree
Hide file tree
Showing 14 changed files with 420 additions and 2,406 deletions.
4 changes: 0 additions & 4 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ plugins {
val assertId = libs.plugins.assert.get().pluginId
val spotlessId = libs.plugins.spotless.get().pluginId
val publishId = libs.plugins.publish.get().pluginId
val koverId = libs.plugins.kover.get().pluginId


dependencies {
kover(projects.parser)
Expand All @@ -27,8 +25,6 @@ dependencies {
}

subprojects {
apply(plugin = koverId)

apply(plugin = assertId)
@Suppress("OPT_IN_USAGE")
configure<PowerAssertGradleExtension> {
Expand Down
1 change: 1 addition & 0 deletions generation/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ plugins {
alias(libs.plugins.serialization)
id(libs.plugins.publish.get().pluginId)
alias(libs.plugins.dokka)
id(libs.plugins.kover.get().pluginId)
}

kotlin { compilerOptions.freeCompilerArgs.add("-Xcontext-receivers") }
Expand Down
2,000 changes: 0 additions & 2,000 deletions kotlin-js-store/yarn.lock

This file was deleted.

1 change: 1 addition & 0 deletions parser/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ plugins {
alias(libs.plugins.serialization)
id(libs.plugins.publish.get().pluginId)
alias(libs.plugins.dokka)
id(libs.plugins.kover.get().pluginId)
}

kotlin {
Expand Down
1 change: 1 addition & 0 deletions typed/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ plugins {
alias(libs.plugins.serialization)
id(libs.plugins.publish.get().pluginId)
alias(libs.plugins.dokka)
id(libs.plugins.kover.get().pluginId)
}

kotlin {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ data class NumberConstraint(
val maximum: Double,
val multipleOf: Double?
) {
constructor(schema: Schema) : this(
constructor(
schema: Schema
) : this(
schema.exclusiveMinimum ?: false,
schema.minimum ?: Double.NEGATIVE_INFINITY,
schema.exclusiveMaximum ?: false,
Expand All @@ -17,14 +19,18 @@ data class NumberConstraint(
}

data class TextConstraint(val maxLength: Int, val minLength: Int, val pattern: String?) {
constructor(schema: Schema) : this(schema.maxLength ?: Int.MAX_VALUE, schema.minLength ?: 0, schema.pattern)
constructor(
schema: Schema
) : this(schema.maxLength ?: Int.MAX_VALUE, schema.minLength ?: 0, schema.pattern)
}

data class CollectionConstraint(
val minItems: Int,
val maxItems: Int,
) {
constructor(schema: Schema) : this(
constructor(
schema: Schema
) : this(
schema.minItems ?: 0,
schema.maxItems ?: Int.MAX_VALUE,
)
Expand All @@ -35,7 +41,9 @@ data class ObjectConstraint(
val minProperties: Int,
val maxProperties: Int,
) {
constructor(schema: Schema): this(
constructor(
schema: Schema
) : this(
schema.minProperties ?: 0,
schema.maxProperties ?: Int.MAX_VALUE,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package io.github.nomisrev.openapi
import io.ktor.http.ContentType
import io.ktor.http.HttpMethod
import io.ktor.http.HttpStatusCode
import kotlinx.serialization.Serializable
import kotlinx.serialization.json.JsonElement

data class Route(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,11 @@ private class OpenAPITransformer(private val openAPI: OpenAPI) {
Type.Basic.Boolean ->
Primitive.Boolean(default("Boolean", String::toBooleanStrictOrNull), description)
Type.Basic.Integer ->
Primitive.Int(default("Integer", String::toIntOrNull), description, NumberConstraint(this))
Primitive.Int(
default("Integer", String::toIntOrNull),
description,
NumberConstraint(this)
)
Type.Basic.Number ->
Primitive.Double(
default("Number", String::toDoubleOrNull),
Expand Down Expand Up @@ -682,7 +686,11 @@ private class OpenAPITransformer(private val openAPI: OpenAPI) {
Pair(
statusCode,
Route.ReturnType(
Primitive.String(null, response.description, TextConstraint(Int.MAX_VALUE, 0, null)),
Primitive.String(
null,
response.description,
TextConstraint(Int.MAX_VALUE, 0, null)

Check warning on line 692 in typed/src/commonMain/kotlin/io/github/nomisrev/openapi/OpenAPITransformer.kt

View check run for this annotation

Codecov / codecov/patch

typed/src/commonMain/kotlin/io/github/nomisrev/openapi/OpenAPITransformer.kt#L688-L692

Added lines #L688 - L692 were not covered by tests
),
response.extensions

Check warning on line 694 in typed/src/commonMain/kotlin/io/github/nomisrev/openapi/OpenAPITransformer.kt

View check run for this annotation

Codecov / codecov/patch

typed/src/commonMain/kotlin/io/github/nomisrev/openapi/OpenAPITransformer.kt#L694

Added line #L694 was not covered by tests
)
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,69 +1,65 @@
package io.github.nomisrev.openapi

import org.junit.jupiter.api.Test
import kotlin.test.assertEquals
import org.junit.jupiter.api.Test

class ConstraintTest {
@Test
fun intRange() {
assertEquals(
Model.Primitive.int(
constraint = NumberConstraint(
constraint =
NumberConstraint(
minimum = 1.0,
maximum = 10.0,
exclusiveMinimum = false,
exclusiveMaximum = false,
multipleOf = null
)
),
Schema(
type = Schema.Type.Basic.Integer,
minimum = 1.0,
maximum = 10.0,
exclusiveMinimum = false,
exclusiveMaximum = false,
multipleOf = null
exclusiveMaximum = false
)
),
Schema(
type = Schema.Type.Basic.Integer,
minimum = 1.0,
maximum = 10.0,
exclusiveMinimum = false,
exclusiveMaximum = false
).toModel("IntRange")
.toModel("IntRange")
)
}

@Test
fun doubleRange() {
assertEquals(
Model.Primitive.double(
constraint = NumberConstraint(
constraint =
NumberConstraint(
minimum = 1.0,
maximum = 10.0,
exclusiveMinimum = false,
exclusiveMaximum = false,
multipleOf = null
)
),
Schema(
type = Schema.Type.Basic.Number,
minimum = 1.0,
maximum = 10.0,
exclusiveMinimum = false,
exclusiveMaximum = false,
multipleOf = null
exclusiveMaximum = false
)
),
Schema(
type = Schema.Type.Basic.Number,
minimum = 1.0,
maximum = 10.0,
exclusiveMinimum = false,
exclusiveMaximum = false
).toModel("IntRange")
.toModel("IntRange")
)
}

@Test
fun text() {
assertEquals(
Model.Primitive.string(
constraint = TextConstraint(
maxLength = 10,
minLength = 1,
pattern = null
)
constraint = TextConstraint(maxLength = 10, minLength = 1, pattern = null)
),
Schema(
type = Schema.Type.Basic.String,
maxLength = 10,
minLength = 1,
pattern = null
).toModel("Text")
Schema(type = Schema.Type.Basic.String, maxLength = 10, minLength = 1, pattern = null)
.toModel("Text")
)
}

Expand All @@ -72,17 +68,15 @@ class ConstraintTest {
assertEquals(
Model.Collection.list(
inner = Model.Primitive.string(),
constraint = CollectionConstraint(
minItems = 1,
maxItems = 10
)
constraint = CollectionConstraint(minItems = 1, maxItems = 10)
),
Schema(
type = Schema.Type.Basic.Array,
items = ReferenceOr.value(Schema(type = Schema.Type.Basic.String)),
maxItems = 10,
minItems = 1
).toModel("List")
type = Schema.Type.Basic.Array,
items = ReferenceOr.value(Schema(type = Schema.Type.Basic.String)),
maxItems = 10,
minItems = 1
)
.toModel("List")
)
}

Expand All @@ -91,18 +85,16 @@ class ConstraintTest {
assertEquals(
Model.Collection.set(
inner = Model.Primitive.string(),
constraint = CollectionConstraint(
minItems = 1,
maxItems = 10
)
constraint = CollectionConstraint(minItems = 1, maxItems = 10)
),
Schema(
type = Schema.Type.Basic.Array,
items = ReferenceOr.value(Schema(type = Schema.Type.Basic.String)),
maxItems = 10,
minItems = 1,
uniqueItems = true
).toModel("List")
type = Schema.Type.Basic.Array,
items = ReferenceOr.value(Schema(type = Schema.Type.Basic.String)),
maxItems = 10,
minItems = 1,
uniqueItems = true
)
.toModel("List")
)
}

Expand All @@ -112,12 +104,16 @@ class ConstraintTest {
Model.obj(
context = NamingContext.Named("Obj"),
properties = listOf(Model.Object.property("name", Model.Primitive.string())),
inline = listOf(Model.Primitive.string())
inline = listOf(Model.Primitive.string()),
constraint = ObjectConstraint(minProperties = 1, maxProperties = 1)
),
Schema(
type = Schema.Type.Basic.Object,
properties = mapOf("name" to ReferenceOr.value(Schema(type = Schema.Type.Basic.String)))
).toModel("Obj")
type = Schema.Type.Basic.Object,
properties = mapOf("name" to ReferenceOr.value(Schema(type = Schema.Type.Basic.String))),
minProperties = 1,
maxProperties = 1
)
.toModel("Obj")
)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,23 @@ import org.junit.jupiter.api.Test
class DefaultArguments {
@Test
fun nullArgumentForNonNullList() {
val actual = Schema(
type = Type.Basic.Object,
properties =
mapOf(
"value" to
value(
Schema(
type = Type.Basic.Array,
items = value(Schema(type = Type.Basic.String)),
default = ExampleValue("null"),
nullable = false
val actual =
Schema(
type = Type.Basic.Object,
properties =
mapOf(
"value" to
value(
Schema(
type = Type.Basic.Array,
items = value(Schema(type = Type.Basic.String)),
default = ExampleValue("null"),
nullable = false
)
)
)
)
)
).toModel("Strings")
)
.toModel("Strings")
val expected =
Model.obj(
context = NamingContext.Named("Strings"),
Expand All @@ -41,21 +43,23 @@ class DefaultArguments {

@Test
fun jsEmptyArrayArgumentForList() {
val actual = Schema(
type = Type.Basic.Object,
properties =
mapOf(
"value" to
value(
Schema(
type = Type.Basic.Array,
items = value(Schema(type = Type.Basic.String)),
default = ExampleValue("[]"),
nullable = false
val actual =
Schema(
type = Type.Basic.Object,
properties =
mapOf(
"value" to
value(
Schema(
type = Type.Basic.Array,
items = value(Schema(type = Type.Basic.String)),
default = ExampleValue("[]"),
nullable = false
)
)
)
)
)
).toModel("Strings")
)
.toModel("Strings")
val expected =
Model.obj(
context = NamingContext.Named("Strings"),
Expand Down
Loading

0 comments on commit e10d8af

Please sign in to comment.