-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(openapi): add converters for various types to handle additional …
…properties - Add BoundedContextConverter to allow additional properties for aggregates - Update CommandResultConverter to use CommandResultCapable and allow additional properties - Modify ConditionConverter to set additional properties for options - Add new converters for WaitSignal, WowMetadata, and MessageHeader - Update BoundedContextSchemaNameConverter to resolve schema names for non-standard library classes
- Loading branch information
Showing
8 changed files
with
151 additions
and
8 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
wow-openapi/src/main/kotlin/me/ahoo/wow/openapi/converter/BoundedContextConverter.kt
This file contains 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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Copyright [2021-present] [ahoo wang <[email protected]> (https://github.com/Ahoo-Wang)]. | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package me.ahoo.wow.openapi.converter | ||
|
||
import io.swagger.v3.oas.models.media.Schema | ||
import me.ahoo.wow.configuration.BoundedContext | ||
|
||
/** | ||
* BoundedContext Converter | ||
*/ | ||
class BoundedContextConverter : TargetTypeModifyConverter() { | ||
|
||
override val targetType: Class<*> = BoundedContext::class.java | ||
|
||
override fun modify(resolvedSchema: Schema<*>): Schema<*> { | ||
val result = checkNotNull(resolvedSchema.properties[BoundedContext::aggregates.name]) | ||
result.additionalProperties = true | ||
result.default = emptyMap<String, Any>() | ||
return resolvedSchema | ||
} | ||
} |
This file contains 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 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 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
30 changes: 30 additions & 0 deletions
30
wow-openapi/src/main/kotlin/me/ahoo/wow/openapi/converter/MessageHeaderConverter.kt
This file contains 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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* Copyright [2021-present] [ahoo wang <[email protected]> (https://github.com/Ahoo-Wang)]. | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package me.ahoo.wow.openapi.converter | ||
|
||
import io.swagger.v3.oas.models.media.Schema | ||
import me.ahoo.wow.api.messaging.Header | ||
|
||
/** | ||
* Header Converter | ||
*/ | ||
class MessageHeaderConverter : TargetTypeModifyConverter() { | ||
|
||
override val targetType: Class<*> = Header::class.java | ||
|
||
override fun modify(resolvedSchema: Schema<*>): Schema<*> { | ||
resolvedSchema.additionalProperties = true | ||
return resolvedSchema | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
wow-openapi/src/main/kotlin/me/ahoo/wow/openapi/converter/WaitSignalConverter.kt
This file contains 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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Copyright [2021-present] [ahoo wang <[email protected]> (https://github.com/Ahoo-Wang)]. | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package me.ahoo.wow.openapi.converter | ||
|
||
import io.swagger.v3.oas.models.media.Schema | ||
import me.ahoo.wow.command.CommandResultCapable | ||
import me.ahoo.wow.command.wait.WaitSignal | ||
|
||
/** | ||
* WaitSignal Converter | ||
*/ | ||
class WaitSignalConverter : TargetTypeModifyConverter() { | ||
|
||
override val targetType: Class<*> = WaitSignal::class.java | ||
|
||
override fun modify(resolvedSchema: Schema<*>): Schema<*> { | ||
val result = checkNotNull(resolvedSchema.properties[CommandResultCapable::result.name]) | ||
result.additionalProperties = true | ||
result.default = emptyMap<String, Any>() | ||
return resolvedSchema | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
wow-openapi/src/main/kotlin/me/ahoo/wow/openapi/converter/WowMetadataConverter.kt
This file contains 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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Copyright [2021-present] [ahoo wang <[email protected]> (https://github.com/Ahoo-Wang)]. | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package me.ahoo.wow.openapi.converter | ||
|
||
import io.swagger.v3.oas.models.media.Schema | ||
import me.ahoo.wow.configuration.WowMetadata | ||
|
||
/** | ||
* WowMetadata Converter | ||
*/ | ||
class WowMetadataConverter : TargetTypeModifyConverter() { | ||
|
||
override val targetType: Class<*> = WowMetadata::class.java | ||
|
||
override fun modify(resolvedSchema: Schema<*>): Schema<*> { | ||
val result = checkNotNull(resolvedSchema.properties[WowMetadata::contexts.name]) | ||
result.additionalProperties = true | ||
result.default = emptyMap<String, Any>() | ||
return resolvedSchema | ||
} | ||
} |
This file contains 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