Skip to content

Commit f8e2e67

Browse files
authored
Preprocessing change underscore_ to x_ and require map key. (opensearch-project#216)
* Preprocessing change underscore_ to x_ Signed-off-by: xil <fridalu66@gmail.com>
1 parent 276c33c commit f8e2e67

3 files changed

Lines changed: 7 additions & 4 deletions

File tree

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
- Add .pyi type hints to the python wheel ([#253](https://github.com/opensearch-project/opensearch-protobufs/pull/253))
8+
- Preprocessing: change prefix from underscore_ to x_ and require map key ([#216](https://github.com/opensearch-project/opensearch-protobufs/pull/216))
89

910
### Changed
1011
- Revert bulk response back to without error response ([#256](https://github.com/opensearch-project/opensearch-protobufs/pull/256))

tools/proto-convert/src/Sanitizer.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {traverse} from "./utils/OpenApiTraverser";
77
* and renaming schema definitions.
88
*/
99
export class Sanitizer {
10+
private static readonly META_PREFIX = "x";
1011
public sanitize(spec: any): any {
1112
this.sanitize_ref(spec);
1213
this.sanitize_spec_name(spec as OpenAPIV3.Document);
@@ -73,7 +74,7 @@ export class Sanitizer {
7374
onResponseSchema: (schema) => this.sanitize_schema(schema),
7475
onParameter: (param, _paramName) => {
7576
if (!('$ref' in param) && param.name && param.name.startsWith('_')) {
76-
param.name = `underscore${param.name}`;
77+
param.name = Sanitizer.META_PREFIX + param.name;
7778
}
7879
}
7980
});
@@ -93,7 +94,7 @@ export class Sanitizer {
9394
public rename_properties_name(properties: Record<string, OpenAPIV3.SchemaObject>) {
9495
for (var propName in properties) {
9596
if(propName.startsWith("_")) {
96-
const newPropName = "underscore" + propName;
97+
const newPropName = Sanitizer.META_PREFIX + propName;
9798
properties[newPropName] = properties[propName];
9899
delete properties[propName];
99100
}
@@ -104,7 +105,7 @@ export class Sanitizer {
104105
for (var index in requireList) {
105106
var propName = requireList[index];
106107
if(propName.startsWith("_")) {
107-
requireList[index] = "underscore" + propName;
108+
requireList[index] = Sanitizer.META_PREFIX + propName;
108109
}
109110
}
110111
}

tools/proto-convert/src/SchemaModifier.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,8 @@ export class SchemaModifier {
224224
[DEFAULT_MAP_KEY]: {
225225
type: "string"
226226
}
227-
}
227+
},
228+
required: [DEFAULT_MAP_KEY]
228229
};
229230
}
230231

0 commit comments

Comments
 (0)