-
Notifications
You must be signed in to change notification settings - Fork 1
Visitors rework, anyOf allOf oneOf support #23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
Toru8P
wants to merge
34
commits into
dev
Choose a base branch
from
visitor_rework
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
85847d3
OneOf, AllOf, AnyOf implemented and supports objects
7cb65f2
decode test added, error fixed
f520ee8
new reworked visitors update started -> interface reworked and encode…
ae36654
decode json object visitor created
73315e7
test import fixed
c7fa3b6
undefined fields throw
b1b5dc2
array of objects implemented for encode and decode json visitors
2946cff
just first element of array
811ac72
all tests resolved
e8a0207
removed validate for type object/array in type field
96c8114
required null check
aa6f820
null or empty for required
c01b619
try catch on visitor creating to detect which schema throws error
0ce5b66
isResolveCombinators false by default, all schema<*> will be treated …
50393ad
not supported schemas exception
f81edcd
don't throw on undefined for combined schemas, implemented composed s…
b41a8cf
don't throw on undefined for combined schemas, implemented composed s…
f9e64ba
fixed check of type
bae4077
check convert of simple type
9f3f21b
Array supports composed objects schemas in each visitor
310adfd
version up and readme updated
9ac4d7e
copyright updated
ce08f6b
reworked oneOf - first valid will be chosen, if there will be more th…
8a3d826
check null value for primitive on encode
fc38368
nullValue into empty scheme
fe34227
Date format support, VisitorSettings created
1c711da
null check for json date field
d5d94d1
date time format support
1075f9c
removed header message if encoding message don`t contain headers map
f3afd26
fixed tests for non header cases
f7c8e89
review update
81924e7
fixed timestamp and id
3c7e43c
fixing null properties
bfa1efa
check for undefined oneOf
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| kotlin.code.style=official | ||
|
|
||
| kotlin_version=1.5.31 | ||
| release_version=0.2.0 | ||
| release_version=0.3.0 | ||
|
|
||
| vcs_url=https://github.com/th2-net/th2-codec-open-api |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -23,12 +23,14 @@ import com.exactpro.th2.codec.openapi.schemacontainer.RequestContainer | |||||||||||||||||||||||||||||
| import com.exactpro.th2.codec.openapi.schemacontainer.ResponseContainer | ||||||||||||||||||||||||||||||
| import com.exactpro.th2.codec.openapi.throwable.DecodeException | ||||||||||||||||||||||||||||||
| import com.exactpro.th2.codec.openapi.throwable.EncodeException | ||||||||||||||||||||||||||||||
| import com.exactpro.th2.codec.openapi.utils.containingFormatOrNull | ||||||||||||||||||||||||||||||
| import com.exactpro.th2.codec.openapi.utils.extractType | ||||||||||||||||||||||||||||||
| import com.exactpro.th2.codec.openapi.utils.getByMethod | ||||||||||||||||||||||||||||||
| import com.exactpro.th2.codec.openapi.utils.getEndPoint | ||||||||||||||||||||||||||||||
| import com.exactpro.th2.codec.openapi.utils.getMethods | ||||||||||||||||||||||||||||||
| import com.exactpro.th2.codec.openapi.utils.getSchema | ||||||||||||||||||||||||||||||
| import com.exactpro.th2.codec.openapi.writer.SchemaWriter | ||||||||||||||||||||||||||||||
| import com.exactpro.th2.codec.openapi.writer.visitors.VisitorFactory | ||||||||||||||||||||||||||||||
| import com.exactpro.th2.codec.openapi.writer.visitors.VisitorSettings | ||||||||||||||||||||||||||||||
| import com.exactpro.th2.common.grpc.MessageGroup | ||||||||||||||||||||||||||||||
| import com.exactpro.th2.common.grpc.RawMessage | ||||||||||||||||||||||||||||||
| import com.exactpro.th2.common.message.plusAssign | ||||||||||||||||||||||||||||||
|
|
@@ -49,12 +51,16 @@ import com.exactpro.th2.common.message.sessionAlias | |||||||||||||||||||||||||||||
| import io.swagger.v3.oas.models.PathItem | ||||||||||||||||||||||||||||||
| import io.swagger.v3.oas.models.parameters.Parameter | ||||||||||||||||||||||||||||||
| import mu.KotlinLogging | ||||||||||||||||||||||||||||||
| import java.lang.IllegalStateException | ||||||||||||||||||||||||||||||
| import java.text.SimpleDateFormat | ||||||||||||||||||||||||||||||
| import java.time.format.DateTimeFormatter | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| class OpenApiCodec(private val dictionary: OpenAPI, settings: OpenApiCodecSettings) : IPipelineCodec { | ||||||||||||||||||||||||||||||
| class OpenApiCodec(private val dictionary: OpenAPI, val settings: OpenApiCodecSettings) : IPipelineCodec { | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| private val typeToSchema: Map<String, HttpRouteContainer> | ||||||||||||||||||||||||||||||
| private val patternToPathItem: List<Pair<UriPattern, PathItem>> | ||||||||||||||||||||||||||||||
| private val schemaWriter = SchemaWriter(dictionary, settings.checkUndefinedFields) | ||||||||||||||||||||||||||||||
| private val schemaWriter = SchemaWriter(dictionary) | ||||||||||||||||||||||||||||||
| private val visitorSettings = VisitorSettings(dictionary, SimpleDateFormat(settings.dateFormat), DateTimeFormatter.ofPattern(settings.dateTimeFormat)) | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| init { | ||||||||||||||||||||||||||||||
| val mapForName = mutableMapOf<String, HttpRouteContainer>() | ||||||||||||||||||||||||||||||
|
|
@@ -125,11 +131,13 @@ class OpenApiCodec(private val dictionary: OpenAPI, settings: OpenApiCodecSettin | |||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| val container = checkNotNull(typeToSchema[messageType]) { "There no message $messageType in dictionary" } | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| builder += createHeaderMessage(container, parsedMessage).apply { | ||||||||||||||||||||||||||||||
| if (parsedMessage.hasParentEventId()) parentEventId = parsedMessage.parentEventId | ||||||||||||||||||||||||||||||
| sessionAlias = parsedMessage.sessionAlias | ||||||||||||||||||||||||||||||
| metadataBuilder.putAllProperties(parsedMessage.metadata.propertiesMap) | ||||||||||||||||||||||||||||||
| LOGGER.trace { "Created header message for ${parsedMessage.messageType}: ${this.messageType}" } | ||||||||||||||||||||||||||||||
| if (container.headers.isNotEmpty() || container.body == null) { | ||||||||||||||||||||||||||||||
| builder += createHeaderMessage(container, parsedMessage).apply { | ||||||||||||||||||||||||||||||
| if (parsedMessage.hasParentEventId()) parentEventId = parsedMessage.parentEventId | ||||||||||||||||||||||||||||||
| sessionAlias = parsedMessage.sessionAlias | ||||||||||||||||||||||||||||||
| metadataBuilder.putAllProperties(parsedMessage.metadata.propertiesMap) | ||||||||||||||||||||||||||||||
| LOGGER.trace { "Created header message for ${parsedMessage.messageType}: ${this.messageType}" } | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||||
|
|
@@ -150,10 +158,13 @@ class OpenApiCodec(private val dictionary: OpenAPI, settings: OpenApiCodecSettin | |||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| LOGGER.debug { "Start of message encoding: ${message.messageType}" } | ||||||||||||||||||||||||||||||
| checkNotNull(messageSchema.type) {"Type of schema [${messageSchema.name}] wasn't filled"} | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| val visitor = VisitorFactory.createEncodeVisitor(container.bodyFormat!!, messageSchema.type, message) | ||||||||||||||||||||||||||||||
| schemaWriter.traverse(visitor, messageSchema) | ||||||||||||||||||||||||||||||
| val visitor = try { | ||||||||||||||||||||||||||||||
| VisitorFactory.createEncodeVisitor(container.bodyFormat!!, messageSchema, message, visitorSettings) | ||||||||||||||||||||||||||||||
| } catch (e: Exception) { | ||||||||||||||||||||||||||||||
| throw IllegalStateException("Cannot create encode visitor for message: ${message.messageType} - ${container.body}", e) | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
| schemaWriter.traverse(visitor, messageSchema, settings.checkUndefinedFields) | ||||||||||||||||||||||||||||||
| val result = visitor.getResult() | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| LOGGER.trace { "Result of encoded message ${message.messageType}: $result" } | ||||||||||||||||||||||||||||||
|
|
@@ -165,9 +176,22 @@ class OpenApiCodec(private val dictionary: OpenAPI, settings: OpenApiCodecSettin | |||||||||||||||||||||||||||||
| container.fillHttpMetadata(metadataBuilder) | ||||||||||||||||||||||||||||||
| metadataBuilder.apply { | ||||||||||||||||||||||||||||||
| putAllProperties(message.metadata.propertiesMap) | ||||||||||||||||||||||||||||||
| this.id = metadata.id | ||||||||||||||||||||||||||||||
| this.timestamp = metadata.timestamp | ||||||||||||||||||||||||||||||
| this.id = message.metadata.id | ||||||||||||||||||||||||||||||
| this.timestamp = message.metadata.timestamp | ||||||||||||||||||||||||||||||
| protocol = message.metadata.protocol | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| when (container) { | ||||||||||||||||||||||||||||||
| is ResponseContainer -> this.putProperties(CODE_FIELD, container.code) | ||||||||||||||||||||||||||||||
| is RequestContainer -> { | ||||||||||||||||||||||||||||||
| this.putProperties(URI_FIELD, if (container.params.isNotEmpty()) { | ||||||||||||||||||||||||||||||
| container.uriPattern.resolve(container.params, message.getMessage(URI_PARAMS_FIELD).orEmpty().fieldsMap.mapValues { it.value.simpleValue }) | ||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||
| container.uriPattern.pattern | ||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||
| this.putProperties(METHOD_FIELD, container.method) | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
| else -> error("Wrong type of Http Route Container") | ||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You won't need it if you'll make |
||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
| body = result | ||||||||||||||||||||||||||||||
| }.build() | ||||||||||||||||||||||||||||||
|
|
@@ -189,7 +213,7 @@ class OpenApiCodec(private val dictionary: OpenAPI, settings: OpenApiCodecSettin | |||||||||||||||||||||||||||||
| builder += runCatching { | ||||||||||||||||||||||||||||||
| decodeBody(message, messages[1].rawMessage!!) | ||||||||||||||||||||||||||||||
| }.getOrElse { | ||||||||||||||||||||||||||||||
| throw DecodeException("Cannot parse body of http message", it) | ||||||||||||||||||||||||||||||
| throw DecodeException("Cannot decode body of http message", it) | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
|
|
@@ -198,57 +222,77 @@ class OpenApiCodec(private val dictionary: OpenAPI, settings: OpenApiCodecSettin | |||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| private fun decodeBody(header: Message, rawMessage: RawMessage): Message { | ||||||||||||||||||||||||||||||
| val body = rawMessage.body | ||||||||||||||||||||||||||||||
| val (messageType, container) = searchContainer(header, rawMessage.metadata) | ||||||||||||||||||||||||||||||
| val schema = dictionary.getEndPoint(checkNotNull(container.body) { "Container: $messageType did not contain schema body" }) | ||||||||||||||||||||||||||||||
| val format = checkNotNull(container.bodyFormat) { "Container: $messageType did not contain schema bodyFormat" } | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| val visitor = try { | ||||||||||||||||||||||||||||||
| VisitorFactory.createDecodeVisitor(format, schema, body, visitorSettings) | ||||||||||||||||||||||||||||||
| } catch (e: Exception) { | ||||||||||||||||||||||||||||||
| throw IllegalStateException("Cannot create decode visitor for message: ${header.messageType} - ${container.body}", e) | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| schemaWriter.traverse(visitor, schema, settings.checkUndefinedFields) | ||||||||||||||||||||||||||||||
| return visitor.getResult().apply { | ||||||||||||||||||||||||||||||
| if(rawMessage.hasParentEventId()) parentEventId = rawMessage.parentEventId | ||||||||||||||||||||||||||||||
| sessionAlias = rawMessage.sessionAlias | ||||||||||||||||||||||||||||||
| this.messageType = messageType | ||||||||||||||||||||||||||||||
| metadataBuilder.apply { | ||||||||||||||||||||||||||||||
| id = rawMessage.metadata.id | ||||||||||||||||||||||||||||||
| timestamp = rawMessage.metadata.timestamp | ||||||||||||||||||||||||||||||
| protocol = rawMessage.metadata.protocol | ||||||||||||||||||||||||||||||
| putAllProperties(rawMessage.metadata.propertiesMap) | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
| }.build() | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| val bodyFormat = header.getList(HEADERS_FIELD) | ||||||||||||||||||||||||||||||
| private fun searchContainer(header: Message, rawMetadata: RawMessageMetadata): Pair<String, HttpRouteContainer> { | ||||||||||||||||||||||||||||||
| val headerFormat = header.getList(HEADERS_FIELD) | ||||||||||||||||||||||||||||||
| ?.first { it.messageValue.getString("name") == "Content-Type" } | ||||||||||||||||||||||||||||||
| ?.messageValue | ||||||||||||||||||||||||||||||
| ?.getString("value") | ||||||||||||||||||||||||||||||
| ?.extractType() ?: "null" | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| val uri: String | ||||||||||||||||||||||||||||||
| val method: String | ||||||||||||||||||||||||||||||
| val schemaFormat: String | ||||||||||||||||||||||||||||||
| var code = "" | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| val pairFound: Pair<UriPattern, PathItem> | ||||||||||||||||||||||||||||||
| val messageType: String | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| val patternToPathItem: Pair<UriPattern, PathItem> | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| val messageSchema = when (header.messageType) { | ||||||||||||||||||||||||||||||
| when (header.messageType) { | ||||||||||||||||||||||||||||||
| RESPONSE_MESSAGE -> { | ||||||||||||||||||||||||||||||
| uri = requireNotNull(rawMessage.metadata.propertiesMap[URI_PROPERTY]) { "URI property in metadata from response is required" } | ||||||||||||||||||||||||||||||
| method = requireNotNull(rawMessage.metadata.propertiesMap[METHOD_PROPERTY]?.lowercase()) { "Method property in metadata from response is required" } | ||||||||||||||||||||||||||||||
| val uri = requireNotNull(rawMetadata.propertiesMap[URI_PROPERTY]) { "URI property in metadata from response is required" } | ||||||||||||||||||||||||||||||
| method = requireNotNull(rawMetadata.propertiesMap[METHOD_PROPERTY]?.lowercase()) { "Method property in metadata from response is required" } | ||||||||||||||||||||||||||||||
| code = requireNotNull(header.getString(STATUS_CODE_FIELD)) { "Code status field required inside of http response message" } | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| pairFound = checkNotNull(patternToPathItem.firstOrNull { it.first.matches(uri) }) { "Cannot find path-item by uri: $uri" } | ||||||||||||||||||||||||||||||
| dictionary.getEndPoint(pairFound.second.getSchema(method, code, bodyFormat)) | ||||||||||||||||||||||||||||||
| patternToPathItem = checkNotNull(this.patternToPathItem.firstOrNull { it.first.matches(uri) }) { "Cannot find path-item by uri: $uri" } | ||||||||||||||||||||||||||||||
| val content = patternToPathItem.second.getByMethod(method)?.responses?.get(code)?.content | ||||||||||||||||||||||||||||||
| schemaFormat = checkNotNull(content?.containingFormatOrNull(headerFormat)) { | ||||||||||||||||||||||||||||||
| "Schema Response [${patternToPathItem.first.pattern}] with method: [$method] and code: [$code] did not contain type $headerFormat" | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
| messageType = combineName(patternToPathItem.first.pattern, method, code, schemaFormat) | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
| REQUEST_MESSAGE -> { | ||||||||||||||||||||||||||||||
| uri = requireNotNull(header.getString(URI_FIELD)) { "URI field in request is required" } | ||||||||||||||||||||||||||||||
| val uri = requireNotNull(header.getString(URI_FIELD)) { "URI field in request is required" } | ||||||||||||||||||||||||||||||
| method = requireNotNull(header.getString(METHOD_FIELD)) { "Method field in request is required" } | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| pairFound = checkNotNull(patternToPathItem.firstOrNull { it.first.matches(uri) }) { "Cannot find path-item by uri: $uri" } | ||||||||||||||||||||||||||||||
| dictionary.getEndPoint(pairFound.second.getSchema(method, null, bodyFormat)) | ||||||||||||||||||||||||||||||
| patternToPathItem = checkNotNull(this.patternToPathItem.firstOrNull { it.first.matches(uri) }) { "Cannot find path-item by uri: $uri" } | ||||||||||||||||||||||||||||||
| val content = patternToPathItem.second.getByMethod(method)?.requestBody?.content | ||||||||||||||||||||||||||||||
| schemaFormat = checkNotNull(content?.containingFormatOrNull(headerFormat)) { | ||||||||||||||||||||||||||||||
| "Schema Response [${patternToPathItem.first.pattern}] with method: [$method] did not contain type $headerFormat" | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
| messageType = combineName(patternToPathItem.first.pattern, method, code, schemaFormat) | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
| else -> error("Unsupported message type: ${header.messageType}") | ||||||||||||||||||||||||||||||
| else -> error("Unsupported header message type: ${header.messageType}") | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| checkNotNull(messageSchema.type) { "Type of schema [${messageSchema.name}] wasn't filled" } | ||||||||||||||||||||||||||||||
| val container = checkNotNull(typeToSchema[messageType]) { "Container for path: [${patternToPathItem.first.pattern}] with method: [$method], code: [$code] and type [$schemaFormat] wasn't found" } | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| val type = combineName(pairFound.first.pattern, method, code, bodyFormat) | ||||||||||||||||||||||||||||||
| LOGGER.debug { "Container for ${header.messageType} with messageType: $messageType was found" } | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| LOGGER.debug { "Schema for ${header.messageType} with type-name: $type was found" } | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| val visitor = VisitorFactory.createDecodeVisitor(bodyFormat, messageSchema.type, body) | ||||||||||||||||||||||||||||||
| schemaWriter.traverse(visitor, messageSchema) | ||||||||||||||||||||||||||||||
| return visitor.getResult().apply { | ||||||||||||||||||||||||||||||
| if(rawMessage.hasParentEventId()) parentEventId = rawMessage.parentEventId | ||||||||||||||||||||||||||||||
| sessionAlias = rawMessage.sessionAlias | ||||||||||||||||||||||||||||||
| this.messageType = type | ||||||||||||||||||||||||||||||
| metadataBuilder.apply { | ||||||||||||||||||||||||||||||
| id = rawMessage.metadata.id | ||||||||||||||||||||||||||||||
| timestamp = metadata.timestamp | ||||||||||||||||||||||||||||||
| protocol = rawMessage.metadata.protocol | ||||||||||||||||||||||||||||||
| putAllProperties(rawMessage.metadata.propertiesMap) | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
| }.build() | ||||||||||||||||||||||||||||||
| return messageType to container | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
|
|
@@ -291,24 +335,22 @@ class OpenApiCodec(private val dictionary: OpenAPI, settings: OpenApiCodecSettin | |||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| if (container.headers.isNotEmpty()) { | ||||||||||||||||||||||||||||||
| val headerMessage = message.getMessage(HEADER_PARAMS_FIELD).orEmpty() | ||||||||||||||||||||||||||||||
| container.headers.forEach { (name, value) -> | ||||||||||||||||||||||||||||||
| headerMessage[name]?.let { header -> | ||||||||||||||||||||||||||||||
| headers.add(message().apply { | ||||||||||||||||||||||||||||||
| addField("name", name) | ||||||||||||||||||||||||||||||
| addField("value", header.simpleValue) | ||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||
| } ?: run { if (value.required) error("Header param [$name] is required for ${message.messageType} message") } | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
| val headerMessage = message.getMessage(HEADER_PARAMS_FIELD).orEmpty() | ||||||||||||||||||||||||||||||
| container.headers.forEach { (name, value) -> | ||||||||||||||||||||||||||||||
| headerMessage[name]?.let { header -> | ||||||||||||||||||||||||||||||
| headers.add(message().apply { | ||||||||||||||||||||||||||||||
| addField("name", name) | ||||||||||||||||||||||||||||||
| addField("value", header.simpleValue) | ||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||
| } ?: run { if (value.required) error("Header param [$name] is required for ${message.messageType} message") } | ||||||||||||||||||||||||||||||
|
Comment on lines
+340
to
+345
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| addField(HEADERS_FIELD, headers) | ||||||||||||||||||||||||||||||
| this.metadataBuilder.protocol = HEADER_PROTOCOL | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| fun combineName(vararg steps: String) = steps.asSequence().flatMap { it.split(COMBINER_REGEX) }.joinToString("") { it.lowercase().capitalize() } | ||||||||||||||||||||||||||||||
| fun combineName(vararg steps: String) = steps.asSequence().flatMap { it.replace("*","Any").split(COMBINER_REGEX) }.joinToString("") { it.lowercase().capitalize() } | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| companion object { | ||||||||||||||||||||||||||||||
| private val LOGGER = KotlinLogging.logger { } | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extract into utility function?