Skip to content

Commit 68d57af

Browse files
committed
feat: adds support for collection v2.1
Drops support for collection v1, as it has been deprecated in Postman for a long time. aubm#53 aubm#51 aubm#28
1 parent 64c822b commit 68d57af

File tree

7 files changed

+647
-577
lines changed

7 files changed

+647
-577
lines changed

main.go

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,19 @@ import (
1414
)
1515

1616
var (
17-
config = configuration.Config
18-
errUnknownCmd = fmt.Errorf("Command not found, please see the documentation at https://github.com/aubm/postmanerator")
19-
themeManager = &themes.Manager{}
20-
themeRenderer = &themes.Renderer{}
21-
gitAgent = &utils.GitAgent{}
22-
collectionBuilder = &postman.CollectionBuilder{}
23-
collectionV1Parser = &postman.CollectionV1Parser{}
24-
environmentBuilder = &postman.EnvironmentBuilder{}
25-
defaultCommand = &commands.Default{}
26-
getThemeCommand = &commands.GetTheme{}
27-
deleteThemeCommand = &commands.DeleteTheme{}
28-
listThemesCommand = &commands.ListThemes{}
29-
availableCommands = []commands.Command{}
17+
config = configuration.Config
18+
errUnknownCmd = fmt.Errorf("Command not found, please see the documentation at https://github.com/aubm/postmanerator")
19+
themeManager = &themes.Manager{}
20+
themeRenderer = &themes.Renderer{}
21+
gitAgent = &utils.GitAgent{}
22+
collectionBuilder = &postman.CollectionBuilder{}
23+
collectionV210Parser = &postman.CollectionV210Parser{}
24+
environmentBuilder = &postman.EnvironmentBuilder{}
25+
defaultCommand = &commands.Default{}
26+
getThemeCommand = &commands.GetTheme{}
27+
deleteThemeCommand = &commands.DeleteTheme{}
28+
listThemesCommand = &commands.ListThemes{}
29+
availableCommands = []commands.Command{}
3030
)
3131

3232
func init() {
@@ -36,10 +36,10 @@ func init() {
3636
func _init() error {
3737
configuration.Init()
3838
if err := inject.Populate(config, themeManager, defaultCommand, getThemeCommand, deleteThemeCommand,
39-
listThemesCommand, gitAgent, themeRenderer, collectionBuilder, collectionV1Parser, environmentBuilder); err != nil {
39+
listThemesCommand, gitAgent, themeRenderer, collectionBuilder, collectionV210Parser, environmentBuilder); err != nil {
4040
return fmt.Errorf("app initialization failed: %v", err)
4141
}
42-
collectionBuilder.Parsers = append(collectionBuilder.Parsers, collectionV1Parser)
42+
collectionBuilder.Parsers = append(collectionBuilder.Parsers, collectionV210Parser)
4343
availableCommands = append(availableCommands,
4444
defaultCommand,
4545
getThemeCommand,

postman/collection_builder_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
func TestExtractStructuresDefinition(t *testing.T) {
99
// Given
1010
builder := &CollectionBuilder{}
11-
builder.Parsers = append(builder.Parsers, &CollectionV1Parser{})
11+
builder.Parsers = append(builder.Parsers, &CollectionV210Parser{})
1212
expectedStructures := []StructureDefinition{
1313
{Name: "Cat", Description: "A great animal", Fields: []StructureFieldDefinition{
1414
{Name: "id", Description: "A unique identifier for the cat", Type: "int"},

postman/collection_v1.go

Lines changed: 0 additions & 48 deletions
This file was deleted.

postman/collection_v1_parser.go

Lines changed: 0 additions & 183 deletions
This file was deleted.

postman/collection_v210.go

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
package postman
2+
3+
type collectionV210 struct {
4+
Info struct {
5+
Name string `json:"name"`
6+
Description string `json:"description"`
7+
Schema string `json:"schema"`
8+
} `json:"info"`
9+
Item []collectionV210Item `json:"item"`
10+
}
11+
12+
type collectionV210Item struct {
13+
Name string `json:"name"`
14+
Description string `json:"description"`
15+
Event []collectionV210Event `json:"event"`
16+
Item []collectionV210Item `json:"item"`
17+
Request *struct {
18+
Method string `json:"method"`
19+
Header []collectionV210KeyValuePair `json:"header"`
20+
Body struct {
21+
Mode string `json:"mode"`
22+
Raw string `json:"raw"`
23+
FormData []collectionV210KeyValuePair `json:"formdata,omitempty"`
24+
UrlEncoded []collectionV210KeyValuePair `json:"urlencoded,omitempty"`
25+
} `json:"body"`
26+
Url struct {
27+
Raw string `json:"raw"`
28+
Variable []collectionV210KeyValuePair `json:"variable"`
29+
} `json:"url"`
30+
Description string `json:"description"`
31+
} `json:"request,omitempty"`
32+
Response []struct {
33+
Name string `json:"name"`
34+
Status string `json:"status"`
35+
Code int `json:"code"`
36+
Header []collectionV210KeyValuePair `json:"header"`
37+
Body string `json:"body"`
38+
} `json:"response"`
39+
}
40+
41+
type collectionV210Event struct {
42+
Listen string `json:"listen"`
43+
Script struct {
44+
Type string `json:"type"`
45+
Exec []string `json:"exec"`
46+
} `json:"script"`
47+
}
48+
49+
type collectionV210KeyValuePair struct {
50+
Key string `json:"key"`
51+
Value interface{} `json:"value"`
52+
Description string `json:"description"`
53+
}

0 commit comments

Comments
 (0)