Skip to content

Commit

Permalink
chore: FK display name to remove ID if we are linking to a get action (
Browse files Browse the repository at this point in the history
  • Loading branch information
RutZap authored Sep 24, 2024
1 parent 7a3d566 commit ae987d9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
4 changes: 4 additions & 0 deletions tools/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,10 @@ func (g *Generator) makeResponsesForModel(model *proto.Model, pathPrefix string,
},
},
}

// now that we have a link to retrieve the related model, the display name of the field should be the
// name of the related field without the ID suffix; e.g. "Category" instead of "Category id"
config.DisplayName = casing.ToSentenceCase(strings.TrimSuffix(f.Name, "Id"))
}
}

Expand Down
18 changes: 9 additions & 9 deletions tools/testdata/blog/tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@
"path": "$.categoryId"
},
"fieldType": "TYPE_ID",
"displayName": "Category id",
"displayName": "Category",
"displayOrder": 7,
"visible": true,
"link": {
Expand Down Expand Up @@ -411,7 +411,7 @@
"path": "$.categoryId"
},
"fieldType": "TYPE_ID",
"displayName": "Category id",
"displayName": "Category",
"displayOrder": 7,
"visible": true,
"link": {
Expand Down Expand Up @@ -652,7 +652,7 @@
"path": "$.categoryId"
},
"fieldType": "TYPE_ID",
"displayName": "Category id",
"displayName": "Category",
"displayOrder": 7,
"visible": true,
"link": {
Expand Down Expand Up @@ -1157,7 +1157,7 @@
"path": "$.results[*].parentId"
},
"fieldType": "TYPE_ID",
"displayName": "Parent id",
"displayName": "Parent",
"displayOrder": 1,
"visible": true,
"link": {
Expand Down Expand Up @@ -1426,7 +1426,7 @@
"path": "$.results[*].categoryId"
},
"fieldType": "TYPE_ID",
"displayName": "Category id",
"displayName": "Category",
"displayOrder": 7,
"visible": true,
"link": {
Expand Down Expand Up @@ -1761,7 +1761,7 @@
"path": "$.results[*].author.categoryId"
},
"fieldType": "TYPE_ID",
"displayName": "Category id",
"displayName": "Category",
"displayOrder": 7,
"visible": true,
"link": {
Expand Down Expand Up @@ -1901,7 +1901,7 @@
"path": "$.results[*].category.categoryId"
},
"fieldType": "TYPE_ID",
"displayName": "Category id",
"displayName": "Category",
"displayOrder": 7,
"visible": true,
"link": {
Expand Down Expand Up @@ -1948,7 +1948,7 @@
"path": "$.results[*].categoryId"
},
"fieldType": "TYPE_ID",
"displayName": "Category id",
"displayName": "Category",
"displayOrder": 7,
"visible": true,
"link": {
Expand Down Expand Up @@ -2330,7 +2330,7 @@
"path": "$.categoryId"
},
"fieldType": "TYPE_ID",
"displayName": "Category id",
"displayName": "Category",
"displayOrder": 7,
"visible": true,
"link": {
Expand Down

0 comments on commit ae987d9

Please sign in to comment.