Best Hikaku code snippet using de.codecentric.hikaku.endpoints.Endpoint
WadlConverter.kt
Source:WadlConverter.kt
1package de.codecentric.hikaku.converters.wadl2import de.codecentric.hikaku.SupportedFeatures3import de.codecentric.hikaku.SupportedFeatures.Feature4import de.codecentric.hikaku.converters.AbstractEndpointConverter5import de.codecentric.hikaku.converters.EndpointConverterException6import de.codecentric.hikaku.converters.wadl.extensions.getAttribute7import de.codecentric.hikaku.endpoints.*8import de.codecentric.hikaku.extensions.checkFileValidity9import org.w3c.dom.Node10import org.w3c.dom.NodeList11import org.xml.sax.InputSource12import java.io.File13import java.io.StringReader14import java.nio.charset.Charset15import java.nio.charset.StandardCharsets.UTF_816import java.nio.file.Files17import java.nio.file.Path18import javax.xml.parsers.DocumentBuilderFactory19import javax.xml.xpath.XPathConstants.NODESET20import javax.xml.xpath.XPathFactory21/**22 * Extracts and converts [Endpoint]s from a *.wadl* file.23 */24class WadlConverter private constructor(private val wadl: String) : AbstractEndpointConverter() {25 @JvmOverloads26 constructor(wadlFile: File, charset: Charset = UTF_8): this(wadlFile.toPath(), charset)27 @JvmOverloads28 constructor(wadlFile: Path, charset: Charset = UTF_8): this(readFileContent(wadlFile, charset))29 override val supportedFeatures = SupportedFeatures(30 Feature.QueryParameters,31 Feature.HeaderParameters,32 Feature.PathParameters,33 Feature.MatrixParameters,34 Feature.Produces,35 Feature.Consumes36 )37 private val xPath = XPathFactory38 .newInstance()39 .newXPath()40 override fun convert(): Set<Endpoint> {41 try {42 return parseWadl()43 } catch (throwable: Throwable) {44 throw EndpointConverterException(throwable)45 }46 }47 private fun parseWadl(): Set<Endpoint> {48 val doc = DocumentBuilderFactory49 .newInstance()50 .newDocumentBuilder()51 .parse(InputSource(StringReader(wadl)))52 val resources = xPath.evaluate("//resource", doc, NODESET) as NodeList53 val endpoints = mutableSetOf<Endpoint>()54 for (index in 0 until resources.length) {55 endpoints.addAll(createEndpoints(resources.item(index)))56 }57 return endpoints58 }59 private fun createEndpoints(resourceElement: Node): Set<Endpoint> {60 val path = resourceElement.getAttribute("path")61 val methods = xPath.evaluate("//resource[@path=\"$path\"]//method", resourceElement.childNodes, NODESET) as NodeList62 val endpoints: MutableSet<Endpoint> = mutableSetOf()63 for (i in 0 until methods.length) {64 val method = methods.item(i)65 val httpMethod = HttpMethod.valueOf(method.getAttribute("name"))66 endpoints.add(67 Endpoint(68 path = path,69 httpMethod = httpMethod,70 queryParameters = extractQueryParameters(method),71 headerParameters = extractHeaderParameters(method),72 pathParameters = extractPathParameters(method),73 matrixParameters = extractMatrixParameters(method),74 produces = extractResponseMediaTypes(method),75 consumes = extractConsumesMediaTypes(method)76 )77 )78 }79 return endpoints80 }81 private fun extractResponseMediaTypes(method: Node) = extractMediaTypes(method, "response")82 private fun extractConsumesMediaTypes(method: Node) = extractMediaTypes(method, "request")83 private fun extractMediaTypes(method: Node, xmlBaseElement: String): Set<String> {84 val representations = xPath.evaluate("//$xmlBaseElement/representation", method.childNodes, NODESET) as NodeList85 val mediaTypes: MutableSet<String> = mutableSetOf()86 for (i in 0 until representations.length) {87 val parameter = representations.item(i)88 mediaTypes += parameter.getAttribute("mediaType")89 }90 return mediaTypes91 }92 private fun extractPathParameters(method: Node): Set<PathParameter> {93 return extractParameter(method, "template")94 .entries95 .map { PathParameter(it.key) }96 .toSet()97 }98 private fun extractQueryParameters(method: Node): Set<QueryParameter> {99 return extractParameter(method, "query")100 .entries101 .map { QueryParameter(it.key, it.value) }102 .toSet()103 }104 private fun extractHeaderParameters(method: Node): Set<HeaderParameter> {105 return extractParameter(method, "header")106 .entries107 .map { HeaderParameter(it.key, it.value) }108 .toSet()109 }110 private fun extractMatrixParameters(method: Node): Set<MatrixParameter> {111 return extractParameter(method, "matrix")112 .entries113 .map { MatrixParameter(it.key, it.value) }114 .toSet()115 }116 private fun extractParameter(method: Node, style: String): Map<String, Boolean> {117 val parameters = xPath.evaluate("//param[@style=\"$style\"]", method.childNodes, NODESET) as NodeList118 val parameterMap: MutableMap<String, Boolean> = mutableMapOf()119 for (i in 0 until parameters.length) {120 val parameter = parameters.item(i)121 val parameterName = parameter.getAttribute("name")122 val isParameterRequired = "true" == parameter.getAttribute("required")123 parameterMap[parameterName] = isParameterRequired124 }125 return parameterMap126 }127}128private fun readFileContent(wadlFile: Path, charset: Charset): String {129 val fileContentBuilder = StringBuilder()130 try {131 wadlFile.checkFileValidity(".wadl")132 Files.readAllLines(wadlFile, charset)133 .map { line ->134 fileContentBuilder135 .append(line)136 .append("\n")137 }138 } catch (throwable: Throwable) {139 throw EndpointConverterException(throwable)140 }141 val fileContent = fileContentBuilder.toString()142 if (fileContent.isBlank()) {143 throw EndpointConverterException("Given WADL is blank.")144 }145 return fileContent146}...
SpringConverter.kt
Source:SpringConverter.kt
1package de.codecentric.hikaku.converters.spring2import de.codecentric.hikaku.SupportedFeatures3import de.codecentric.hikaku.SupportedFeatures.Feature4import de.codecentric.hikaku.converters.AbstractEndpointConverter5import de.codecentric.hikaku.converters.spring.extensions.*6import de.codecentric.hikaku.endpoints.Endpoint7import de.codecentric.hikaku.endpoints.HttpMethod8import de.codecentric.hikaku.endpoints.HttpMethod.*9import org.springframework.context.ApplicationContext10import org.springframework.web.method.HandlerMethod11import org.springframework.web.servlet.mvc.method.RequestMappingInfo12import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping13/**14 * Extracts and converts [Endpoint]s from a spring [ApplicationContext].15 * @param applicationContext Spring application context16 */17class SpringConverter(private val applicationContext: ApplicationContext) : AbstractEndpointConverter() {18 override val supportedFeatures = SupportedFeatures(19 Feature.QueryParameters,20 Feature.PathParameters,21 Feature.HeaderParameters,22 Feature.MatrixParameters,23 Feature.Produces,24 Feature.Consumes,25 Feature.Deprecation26 )27 override fun convert(): Set<Endpoint> {28 return applicationContext.getBean(RequestMappingHandlerMapping::class.java)29 .handlerMethods30 .flatMap { mappingEntry ->31 mappingEntry.key.paths().flatMap { path ->32 createEndpoints(path, mappingEntry)33 }34 }35 .toSet()36 }37 private fun createEndpoints(path: String, mappingEntry: Map.Entry<RequestMappingInfo, HandlerMethod>): Set<Endpoint> {38 val httpMethods = extractAvailableHttpMethods(mappingEntry)39 val cleanedPath = removeRegex(path)40 val endpoints = httpMethods.map {41 Endpoint(42 path = cleanedPath,43 httpMethod = it,44 queryParameters = mappingEntry.value.hikakuQueryParameters(),45 pathParameters = mappingEntry.value.hikakuPathParameters(),46 headerParameters = mappingEntry.value.hikakuHeaderParameters(),47 matrixParameters = mappingEntry.value.hikakuMatrixParameters(),48 produces = mappingEntry.produces(),49 consumes = mappingEntry.consumes(),50 deprecated = mappingEntry.isEndpointDeprecated()51 )52 }53 .toMutableSet()54 // Spring always adds an OPTIONS http method if it does not exist, but without query and path parameter55 if (!httpMethods.contains(OPTIONS)) {56 endpoints.add(57 Endpoint(58 path = cleanedPath,59 httpMethod = OPTIONS,60 deprecated = mappingEntry.isEndpointDeprecated()61 )62 )63 }64 return endpoints65 }66 private fun removeRegex(path: String): String {67 return path.split('/').joinToString("/") { pathSegment ->68 pathSegment.let {69 when {70 it.contains(':') -> it.replace(Regex(":.*"), "}")71 else -> it72 }73 }74 }75 }76 private fun extractAvailableHttpMethods(mappingEntry: Map.Entry<RequestMappingInfo, HandlerMethod>): Set<HttpMethod> {77 val httpMethods = mappingEntry.key.hikakuHttpMethods()78 // Spring adds all http methods except for TRACE if no http method has been set explicitly79 // OPTIONS is a special case. If it's not added manually it has to be added without any path or query parameters80 return if (httpMethods.isEmpty()) {81 HttpMethod.values()82 .filterNot { it == TRACE }83 .filterNot { it == OPTIONS }84 .toSet()85 } else {86 // Spring always adds a HEAD http method87 httpMethods + HEAD88 }89 }90 companion object {91 @JvmField92 val IGNORE_ERROR_ENDPOINT: (Endpoint) -> Boolean = { endpoint -> endpoint.path == "/error" }93 }94}...
OpenApiConverter.kt
Source:OpenApiConverter.kt
1package de.codecentric.hikaku.converters.openapi2import de.codecentric.hikaku.SupportedFeatures3import de.codecentric.hikaku.SupportedFeatures.Feature4import de.codecentric.hikaku.converters.AbstractEndpointConverter5import de.codecentric.hikaku.converters.EndpointConverterException6import de.codecentric.hikaku.converters.openapi.extensions.httpMethods7import de.codecentric.hikaku.converters.openapi.extractors.*8import de.codecentric.hikaku.endpoints.Endpoint9import de.codecentric.hikaku.endpoints.HttpMethod10import de.codecentric.hikaku.extensions.checkFileValidity11import io.swagger.v3.oas.models.Operation12import io.swagger.v3.parser.OpenAPIV3Parser13import java.io.File14import java.nio.charset.Charset15import java.nio.charset.StandardCharsets.UTF_816import java.nio.file.Files.readAllLines17import java.nio.file.Path18/**19 * Extracts and converts [Endpoint]s from OpenAPI 3.0.X document. Either a *.yaml*, *.yml* or a *.json* file.20 */21class OpenApiConverter private constructor(private val specificationContent: String) : AbstractEndpointConverter() {22 @JvmOverloads23 constructor(openApiSpecification: File, charset: Charset = UTF_8): this(openApiSpecification.toPath(), charset)24 @JvmOverloads25 constructor(openApiSpecification: Path, charset: Charset = UTF_8): this(readFileContent(openApiSpecification, charset))26 override val supportedFeatures = SupportedFeatures(27 Feature.QueryParameters,28 Feature.PathParameters,29 Feature.HeaderParameters,30 Feature.Produces,31 Feature.Consumes,32 Feature.Deprecation33 )34 override fun convert(): Set<Endpoint> {35 try {36 return parseOpenApi()37 } catch (throwable: Throwable) {38 throw EndpointConverterException(throwable)39 }40 }41 private fun parseOpenApi(): Set<Endpoint> {42 val swaggerParseResult = OpenAPIV3Parser().readContents(specificationContent, null, null)43 val openApi = swaggerParseResult.openAPI ?: throw openApiParseException(swaggerParseResult.messages)44 val extractConsumesMediaTypes = ConsumesExtractor(openApi)45 val extractProduceMediaTypes = ProducesExtractor(openApi)46 val extractQueryParameters = QueryParameterExtractor(openApi)47 val extractHeaderParameters = HeaderParameterExtractor(openApi)48 val extractPathParameters = PathParameterExtractor(openApi)49 return openApi.paths.flatMap { (path, pathItem) ->50 val commonQueryParameters = extractQueryParameters(pathItem.parameters)51 val commonPathParameters = extractPathParameters(pathItem.parameters)52 val commonHeaderParameters = extractHeaderParameters(pathItem.parameters)53 pathItem.httpMethods().map { (httpMethod: HttpMethod, operation: Operation?) ->54 Endpoint(55 path = path,56 httpMethod = httpMethod,57 queryParameters = commonQueryParameters.union(extractQueryParameters(operation?.parameters)),58 pathParameters = commonPathParameters.union(extractPathParameters(operation?.parameters)),59 headerParameters = commonHeaderParameters.union(extractHeaderParameters(operation?.parameters)),60 consumes = extractConsumesMediaTypes(operation),61 produces = extractProduceMediaTypes(operation),62 deprecated = operation?.deprecated ?: false63 )64 }65 }66 .toSet()67 }68}69private fun readFileContent(openApiSpecification: Path, charset: Charset): String {70 try {71 openApiSpecification.checkFileValidity(".json", ".yaml", ".yml")72 } catch (throwable: Throwable) {73 throw EndpointConverterException(throwable)74 }75 val fileContent = readAllLines(openApiSpecification, charset).joinToString("\n")76 if (fileContent.isBlank()) {77 throw EndpointConverterException("Given OpenAPI file is blank.")78 }79 return fileContent80}81private fun openApiParseException(reasons: List<String>)82 = EndpointConverterException("Failed to parse OpenAPI spec. Reasons:\n${reasons.joinToString("\n")}")
Hikaku.kt
Source:Hikaku.kt
1package de.codecentric.hikaku2import de.codecentric.hikaku.SupportedFeatures.Feature3import de.codecentric.hikaku.converters.EndpointConverter4import de.codecentric.hikaku.endpoints.Endpoint5import de.codecentric.hikaku.reporters.MatchResult6import de.codecentric.hikaku.reporters.Reporter7import kotlin.test.fail8/**9 * Entry point for writing a hikaku test. Provide the [EndpointConverter]s and call [match] to test if the specification and the implementation of your REST-API match.10 * @param specification An [EndpointConverter] which converts your specification for the equality check.11 * @param implementation An [EndpointConverter] which converts your implementation for the equality check.12 * @param config The configuration is optional. It lets you control the matching.13 */14class Hikaku(15 private val specification: EndpointConverter,16 private val implementation: EndpointConverter,17 var config: HikakuConfig = HikakuConfig()18) {19 private val supportedFeatures = SupportedFeatures(specification.supportedFeatures.intersect(implementation.supportedFeatures))20 private fun Set<Endpoint>.applyConfig(config: HikakuConfig): List<Endpoint> {21 val result = this.toMutableList()22 config.filters.forEach {23 result.removeAll(this.filter(it))24 }25 return result26 }27 private fun reportResult(matchResult: MatchResult) {28 config.reporters.forEach { it.report(matchResult) }29 }30 /**31 * Calling this method creates a [MatchResult]. It will be passed to the [Reporter] defined in the configuration and call [assert] with the end result.32 */33 fun match() {34 val specificationEndpoints = specification35 .conversionResult36 .applyConfig(config)37 .toSet()38 val implementationEndpoints = implementation39 .conversionResult40 .applyConfig(config)41 .toSet()42 val notExpected = implementationEndpoints.toMutableSet()43 val notFound = specificationEndpoints.toMutableSet()44 specificationEndpoints.forEach { currentEndpoint ->45 if (iterableContains(notExpected, currentEndpoint)) {46 notExpected.removeIf(endpointMatches(currentEndpoint))47 notFound.removeIf(endpointMatches(currentEndpoint))48 }49 }50 reportResult(51 MatchResult(52 supportedFeatures,53 specificationEndpoints,54 implementationEndpoints,55 notFound,56 notExpected57 )58 )59 if (notExpected.isNotEmpty() || notFound.isNotEmpty()) {60 fail("Implementation does not match specification.")61 }62 }63 private fun endpointMatches(otherEndpoint: Endpoint): (Endpoint) -> Boolean {64 return {65 var matches = true66 matches = matches && it.path == otherEndpoint.path67 matches = matches && it.httpMethod == otherEndpoint.httpMethod68 supportedFeatures.forEach { feature ->69 matches = when (feature) {70 Feature.QueryParameters -> matches && it.queryParameters == otherEndpoint.queryParameters71 Feature.PathParameters -> matches && it.pathParameters == otherEndpoint.pathParameters72 Feature.HeaderParameters -> matches && it.headerParameters == otherEndpoint.headerParameters73 Feature.MatrixParameters -> matches && it.matrixParameters == otherEndpoint.matrixParameters74 Feature.Produces -> matches && it.produces == otherEndpoint.produces75 Feature.Consumes -> matches && it.consumes == otherEndpoint.consumes76 Feature.Deprecation -> matches && it.deprecated == otherEndpoint.deprecated77 }78 }79 matches80 }81 }82 private fun iterableContains(notExpected: Set<Endpoint>, value: Endpoint) = notExpected.any(endpointMatches(value))83}...
RamlConverter.kt
Source:RamlConverter.kt
1package de.codecentric.hikaku.converters.raml2import de.codecentric.hikaku.SupportedFeatures3import de.codecentric.hikaku.SupportedFeatures.Feature4import de.codecentric.hikaku.converters.AbstractEndpointConverter5import de.codecentric.hikaku.converters.EndpointConverterException6import de.codecentric.hikaku.converters.raml.extensions.*7import de.codecentric.hikaku.endpoints.Endpoint8import de.codecentric.hikaku.extensions.checkFileValidity9import org.raml.v2.api.RamlModelBuilder10import org.raml.v2.api.RamlModelResult11import org.raml.v2.api.model.v10.resources.Resource12import java.io.File13import java.nio.file.Path14class RamlConverter(private val ramlSpecification: File) : AbstractEndpointConverter() {15 constructor(ramlSpecification: Path) : this(ramlSpecification.toFile())16 override val supportedFeatures = SupportedFeatures(17 Feature.QueryParameters,18 Feature.PathParameters,19 Feature.HeaderParameters,20 Feature.Produces,21 Feature.Consumes,22 Feature.Deprecation23 )24 override fun convert(): Set<Endpoint> {25 val ramlParserResult: RamlModelResult?26 try {27 ramlSpecification.checkFileValidity(".raml")28 ramlParserResult = RamlModelBuilder().buildApi(ramlSpecification)29 } catch(throwable: Throwable) {30 throw EndpointConverterException(throwable)31 }32 if (ramlParserResult.isVersion08) {33 throw EndpointConverterException("Unsupported RAML version")34 }35 if (ramlParserResult.hasErrors()) {36 throw EndpointConverterException(ramlParserResult.validationResults.joinToString("\n"))37 }38 return ramlParserResult.apiV10?.resources()?.let { resourceList ->39 resourceList.flatMap { findEndpoints(it) }40 }41 .orEmpty()42 .toSet()43 }44 private fun findEndpoints(resource: Resource): List<Endpoint> {45 val endpoints = mutableListOf<Endpoint>()46 if (resource.resources().isNotEmpty()) {47 endpoints += resource.resources().flatMap {48 return@flatMap findEndpoints(it)49 }50 }51 if (resource.methods().isNotEmpty()) {52 endpoints += resource.methods().map {53 Endpoint(54 path = resource.resourcePath(),55 httpMethod = it.hikakuHttpMethod(),56 queryParameters = it.hikakuQueryParameters(),57 pathParameters = it.resource()?.hikakuPathParameters().orEmpty(),58 headerParameters = it?.hikakuHeaderParameters().orEmpty(),59 consumes = it.requestMediaTypes(),60 produces = it.responseMediaTypes(),61 deprecated = it.isEndpointDeprecated()62 )63 }64 }65 return endpoints66 }67}...
RamlConverterPathParameterTest.kt
Source:RamlConverterPathParameterTest.kt
1package de.codecentric.hikaku.converters.raml2import de.codecentric.hikaku.endpoints.Endpoint3import de.codecentric.hikaku.endpoints.HttpMethod.GET4import de.codecentric.hikaku.endpoints.HttpMethod.POST5import de.codecentric.hikaku.endpoints.PathParameter6import org.assertj.core.api.Assertions.assertThat7import org.junit.jupiter.api.Test8import java.nio.file.Paths9class RamlConverterPathParameterTest {10 @Test11 fun `simple path parameter declaration`() {12 //given13 val file = Paths.get(this::class.java.classLoader.getResource("path_parameter/simple_path_parameter.raml").toURI())14 val specification = setOf(15 Endpoint(16 path = "/todos/{id}",17 httpMethod = GET,18 pathParameters = setOf(19 PathParameter("id")20 )21 )22 )23 //when24 val implementation = RamlConverter(file).conversionResult25 //then26 assertThat(implementation).containsExactlyInAnyOrderElementsOf(specification)27 }28 @Test29 fun `nested path parameter declaration`() {30 //given31 val file = Paths.get(this::class.java.classLoader.getResource("path_parameter/nested_path_parameter.raml").toURI())32 val specification = setOf(33 Endpoint("/todos", POST),34 Endpoint(35 path = "/todos/{id}",36 httpMethod = GET,37 pathParameters = setOf(38 PathParameter("id")39 )40 )41 )42 //when43 val implementation = RamlConverter(file).conversionResult44 //then45 assertThat(implementation).containsExactlyInAnyOrderElementsOf(specification)46 }47}...
JaxRsConverterPathParametersTest.kt
Source:JaxRsConverterPathParametersTest.kt
1package de.codecentric.hikaku.converters.jaxrs2import de.codecentric.hikaku.endpoints.Endpoint3import de.codecentric.hikaku.endpoints.HttpMethod.GET4import de.codecentric.hikaku.endpoints.PathParameter5import org.assertj.core.api.Assertions.assertThat6import org.junit.jupiter.api.Test7class JaxRsConverterPathParametersTest {8 @Test9 fun `no path parameter`() {10 //given11 val specification = setOf(12 Endpoint("/todos/{id}", GET)13 )14 //when15 val result = JaxRsConverter("test.jaxrs.pathparameters.nopathparameter").conversionResult16 //then17 assertThat(result).containsExactlyInAnyOrderElementsOf(specification)18 }19 @Test20 fun `path parameter on function`() {21 //given22 val specification = setOf(23 Endpoint(24 path = "/todos/{id}",25 httpMethod = GET,26 pathParameters = setOf(27 PathParameter("id")28 )29 )30 )31 //when32 val result = JaxRsConverter("test.jaxrs.pathparameters.onfunction").conversionResult33 //then34 assertThat(result).containsExactlyInAnyOrderElementsOf(specification)35 }36}...
MatchResult.kt
Source:MatchResult.kt
1package de.codecentric.hikaku.reporters2import de.codecentric.hikaku.SupportedFeatures3import de.codecentric.hikaku.endpoints.Endpoint4/**5 * Contains the complete result.6 * @param supportedFeatures Contains all features which have been used for the match.7 * @param specificationEndpoints All [Endpoint]s extracted from the specification.8 * @param implementationEndpoints All [Endpoint]s extracted from the implementation.9 * @param notFound A [Set] of [Endpoint]s which were expected due to their existence in the specification, but which couldn't be found.10 * @param notExpected A [Set] of [Endpoint]s which have been found in the implementation, but which were unexpected, because they don't exist in the specification.11 */12data class MatchResult(13 val supportedFeatures: SupportedFeatures,14 val specificationEndpoints: Set<Endpoint>,15 val implementationEndpoints: Set<Endpoint>,16 val notFound: Set<Endpoint>,17 val notExpected: Set<Endpoint>18)...
Endpoint
Using AI Code Generation
1 import de.codecentric.hikaku.endpoints.*2 import de.codecentric.hikaku.endpoints.*3 import de.codecentric.hikaku.endpoints.*4 import de.codecentric.hikaku.endpoints.*5 import de.codecentric.hikaku.endpoints.*6 import de.codecentric.hikaku.endpoints.*7 import de.codecentric.hikaku.endpoints.*8 import de.codecentric.hikaku.endpoints.*9 import de.codecentric.hikaku.endpoints.*10 import de.codecentric.hikaku.endpoints.*11 import de.codecentric.hikaku.endpoints.*12 import de.codecentric.hikaku.endpoints.*13 import de.codecentric.hikaku.converters.jaxrs.*14 import de.codecentric.hikaku.converters.spring.*15 import de.codecentric.hikaku.converters.springmvc.*16 import de.codecentric.hik
Endpoint
Using AI Code Generation
1import de.codecentric.hikaku.endpoints.Endpoint2import de.codecentric.hikaku.endpoints.HttpMethod.GET3import de.codecentric.hikaku.endpoints.HttpMethod.POST4import de.codecentric.hikaku.converters.endpoints.EndpointsConverter5import de.codecentric.hikaku.converters.openapi.OpenApiConverter6class ContractTest {7 fun `test contract`() {8 val openApi = File("path/to/openapi.yaml")9 val endpoints = setOf(10 Endpoint("/api/endpoint1", GET),11 Endpoint("/api/endpoint2", POST)12 val convertedOpenApi = OpenApiConverter(openApi).convert()13 val convertedEndpoints = EndpointsConverter(endpoints).convert()14 }15}16See the [open issues](
Endpoint
Using AI Code Generation
1val endpoint1 = Endpoint("/api/v1", HttpMethod.GET)2val endpoint2 = Endpoint("/api/v1", HttpMethod.GET)3val endpoint1 = Endpoint("/api/v1", HttpMethod.GET)4val endpoint2 = Endpoint("/api/v1", HttpMethod.POST)5val endpoint1 = Endpoint("/api/v1", HttpMethod.GET)6val endpoint2 = Endpoint("/api/v1", HttpMethod.GET)7val endpoint3 = Endpoint("/api/v2", HttpMethod.GET)8val endpoint1 = Endpoint("/api/v1", HttpMethod.GET)9val endpoint2 = Endpoint("/api/v1", HttpMethod.GET, produces = setOf("application/json"))10val endpoint1 = Endpoint("/api/v1", HttpMethod.GET)11val endpoint2 = Endpoint("/api/v1", HttpMethod.GET, produces = setOf("application/json"))12val endpoint3 = Endpoint("/api/v1", HttpMethod.GET, produces = setOf("application/xml"))13val endpoint1 = Endpoint("/api/v1", HttpMethod.GET)14val endpoint2 = Endpoint("/api/v1", HttpMethod.GET, consumes = setOf("application/json"))15val endpoint1 = Endpoint("/api/v1", HttpMethod.GET)16val endpoint2 = Endpoint("/api/v1", HttpMethod.GET, consumes = setOf("application/json"))17val endpoint3 = Endpoint("/api/v1", HttpMethod.GET, consumes = setOf("application/xml"))18val endpoint1 = Endpoint("/api/v1", HttpMethod.GET)19val endpoint2 = Endpoint("/api/v1",
Endpoint
Using AI Code Generation
1val converter = JacksonConverter()2val response = endpoint.get("/todos", converter)3val hikaku = Hikaku()4val converter = JacksonConverter()5val response = endpoint.get("/todos", converter)6val specification = Specification(7SpecificationVersion("1.0"),8SpecificationTitle("Todo API"),9SpecificationDescription("Specification of Todo API"),10SpecificationVendor("de.codecentric"),11SpecificationContact("
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!