in.specmatic.conversions.OpenApiOperation.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of specmatic-core Show documentation
Show all versions of specmatic-core Show documentation
Turn your contracts into executable specifications. Contract Driven Development - Collaboratively Design & Independently Deploy MicroServices & MicroFrontends.
Deprecation Notice for group ID "in.specmatic"
******************************************************************************************************
Updates for "specmatic-core" will no longer be available under the deprecated group ID "in.specmatic".
Please update your dependencies to use the new group ID "io.specmatic".
******************************************************************************************************
package `in`.specmatic.conversions
import `in`.specmatic.core.HttpQueryParamPattern
import `in`.specmatic.core.pattern.ContractException
import `in`.specmatic.core.pattern.Pattern
import `in`.specmatic.core.pattern.QueryParameterArrayPattern
import `in`.specmatic.core.pattern.QueryParameterScalarPattern
import io.swagger.v3.oas.models.Operation
import io.swagger.v3.oas.models.parameters.QueryParameter
class OpenApiOperation(val operation: Operation) {
fun validateParameters() {
operation.parameters.orEmpty().forEach { parameter ->
if(parameter.name == null)
throw ContractException("A parameter does not have a name.")
if(parameter.schema == null)
throw ContractException("A parameter does not have a schema.")
if(parameter.schema.type == "array" && parameter.schema.items == null)
throw ContractException("A parameter of type \"array\" has not defined \"items\".")
}
}
}