Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
117 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Item A to-do item. | ||
interface Item { | ||
// createdAt is the time the to-do item was created. | ||
createdAt?: Date | ||
|
||
// id is the id of the item. This field is read-only. | ||
id?: number | ||
|
||
// text is the to-do item text. This field is required. | ||
text: string | ||
} | ||
|
||
// AddItemInput params. | ||
interface AddItemInput { | ||
// item is the item to add. This field is required. | ||
item: string | ||
} | ||
|
||
// GetItemsOutput params. | ||
interface GetItemsOutput { | ||
// items is the list of to-do items. | ||
items?: Item[] | ||
} | ||
|
||
// RemoveItemInput params. | ||
interface RemoveItemInput { | ||
// id is the id of the item to remove. | ||
id?: number | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,27 @@ | ||
package tstypes_test | ||
|
||
import ( | ||
"bytes" | ||
"io/ioutil" | ||
"testing" | ||
|
||
"github.com/apex/rpc/generators/tstypes" | ||
"github.com/apex/rpc/schema" | ||
"github.com/tj/assert" | ||
) | ||
|
||
func TestGenerate(t *testing.T) { | ||
exp, err := ioutil.ReadFile("testdata/todo_types.ts") | ||
assert.NoError(t, err, "reading fixture") | ||
|
||
schema, err := schema.Load("../../examples/todo/schema.json") | ||
assert.NoError(t, err, "loading schema") | ||
|
||
var act bytes.Buffer | ||
err = tstypes.Generate(&act, schema) | ||
assert.NoError(t, err, "generating") | ||
|
||
// ioutil.WriteFile("testdata/todo_types.ts", act.Bytes(), 0755) | ||
|
||
assert.Equal(t, string(exp), act.String()) | ||
} |