Skip to content

Commit 0429052

Browse files
authored
Merge branch 'opensearch-project:main' into main
2 parents 2f1c9ae + 008e066 commit 0429052

4 files changed

Lines changed: 16 additions & 1 deletion

File tree

.github/workflows/publish-release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,5 +63,5 @@ jobs:
6363
generate_release_notes: true
6464
files: |
6565
opensearch-protobufs-java.tar.gz
66-
opensearch_protobufs-*-py3-none-any.whl
66+
dist/opensearch_protobufs-*-py3-none-any.whl
6767
opensearch-protobufs-*.zip

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
55
## [Unreleased]
66
### Added
77
- Publish opensearch-protos python package to PyPi. ([#183](https://github.com/opensearch-project/opensearch-protobufs/pull/183))
8+
- Proto Convertion tooling support null value ([#189](https://github.com/opensearch-project/opensearch-protobufs/pull/189))
89

910
### Changed
1011
- update `score` protobuf type ([#179](https://github.com/opensearch-project/opensearch-protobufs/pull/179))

tools/proto-convert/src/SchemaModifier.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,14 @@ export class SchemaModifier {
2020
onSchemaProperty: (schema) => {
2121
this.deduplicateEnumValue(schema)
2222
this.handleAdditionalPropertiesUndefined(schema)
23+
this.convertNullTypeToNullValue(schema)
2324
this.collapseOrMergeOneOfArray(schema)
2425
},
2526
onSchema: (schema, schemaName) => {
2627
if (!schema || isReferenceObject(schema)) return;
2728
this.deduplicateEnumValue(schema)
2829
this.handleAdditionalPropertiesUndefined(schema)
30+
this.convertNullTypeToNullValue(schema)
2931
this.handleOneOfConst(schema, schemaName)
3032
this.collapseOrMergeOneOfArray(schema)
3133
this.collapseOneOfObjectPropContainsTitleSchema(schema)
@@ -333,4 +335,11 @@ export class SchemaModifier {
333335

334336
schema.enum = Array.from(enumSet)
335337
}
338+
339+
// Converts type: "null" to type: NullValue for protobuf compatibility
340+
convertNullTypeToNullValue(schema: OpenAPIV3.SchemaObject): void {
341+
if ((schema.type as any) === 'null') {
342+
(schema as any).type = 'NullValue';
343+
}
344+
}
336345
}

tools/proto-convert/src/config/protobuf-schema-template/custom_message.mustache

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,8 @@ message GeneralNumber {
3030
double double_value = 4;
3131
}
3232
}
33+
34+
enum NullValue {
35+
NULL_VALUE_UNSPECIFIED = 0;
36+
NULL_VALUE_NULL = 1;
37+
}

0 commit comments

Comments
 (0)