Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dump function annotations in thrift files #171

Merged
merged 1 commit into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion tool/trimmer/dump/dump_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,13 @@ func TestDumpSingle(t *testing.T) {
filename := filepath.Join("..", "test_cases", "sample1.thrift")
ast, err := parser.ParseFile(filename, []string{"test_cases"}, true)
test.Assert(t, err == nil, err)
_, err = DumpIDL(ast)
out, err := DumpIDL(ast)
test.Assert(t, err == nil, err)

// tests for function annotations
test.Assert(t, strings.Contains(out, "api.get"), "output should contains function annotations")
test.Assert(t, strings.Contains(out, "api.post"), "output should contains function annotations")
test.Assert(t, strings.Contains(out, "api.put"), "output should contains function annotations")
}

func TestDumpMany(t *testing.T) {
Expand Down
1 change: 1 addition & 0 deletions tool/trimmer/dump/field_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ const FunctionTemplate = `
{{- if $index}},{{end -}}{{- template "SingleLineField" .}}
{{- end}})
{{- end}}
{{- template "Annotations" .Annotations -}}
{{- end -}}
`

Expand Down
9 changes: 4 additions & 5 deletions tool/trimmer/test_cases/sample1.thrift
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,13 @@ service EmployeeService extends sample1b.GetPerson {
service ProjectService {
Project getProject(1: string id)
oneway void addProject(1: Project project)
void updateProject(1: string id,
2: Project project)
void updateProject(1: string id, 2: Project project)
}

service CompanyService {
Company getCompany(1: string id)
void addCompany(1: Company company) throws(1: samlpe1bAnotherException exc)
void updateCompany(1: string id, 2: Company company)
Company getCompany(1: string id) (api.get = "/company")
void addCompany(1: Company company) throws(1: samlpe1bAnotherException exc) (api.put = "/company")
void updateCompany(1: string id, 2: Company company) (api.post = "/company")
list<sample1b.Department> getDepartments(1: string company_id)
void anotherUselessMethod(1: MaybeUseless useless)
}
Expand Down
Loading