Skip to content

Commit 66fc1fd

Browse files
authored
Improve route serialization (#1996)
* Unexport fields in serialization * Add generated code disclaimer * Use string in versions map for serialization
1 parent 4f5a5c8 commit 66fc1fd

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

compiler/src/dump/extract-routes.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,18 +79,18 @@ export class Forest {
7979
function serializeNode (node: Node): string {
8080
let output: string = ''
8181
const template: string = `{
82-
Name: "${node.name}",
83-
Path: []byte("${node.path}"),
82+
name: "${node.name}",
83+
path: []byte("${node.path}"),
8484
`
8585

8686
output += template
8787
if (node.children.length > 0) {
8888
for (const child of node.children) {
8989
if (child.isVariable) {
90-
output += `Variable: &node${serializeNode(child)}`
90+
output += `variable: &node${serializeNode(child)}`
9191
}
9292
}
93-
output += `Children: []node{
93+
output += `children: []node{
9494
`
9595
for (const child of node.children) {
9696
if (!child.isVariable) {
@@ -124,13 +124,14 @@ function serializeForest (forest: Forest): string {
124124
let output: string = ''
125125
const begin: string = `package esroutes
126126
127+
// Code generated from the elasticsearch-specification DO NOT EDIT.
127128
var routes = forest{
128-
map[byte]trees{
129+
map[string]trees{
129130
`
130131
output += begin
131132

132133
for (const [version, tree] of forest.byVersion) {
133-
output += `\n'${version}': { ByMethod: map[string]node{`
134+
output += `\n"${version}": { byMethod: map[string]node{`
134135
output += serializeTree(tree)
135136
output += '},'
136137
}

0 commit comments

Comments
 (0)