@@ -14,10 +14,11 @@ import (
14
14
// Convert yaml2json: https://github.com/bronze1man/yaml2json ... yaml2json_darwin_amd64
15
15
16
16
type Options struct {
17
+ OpenAPIFile string `short:"O" long:"openapiFile" description:"Input Swagger File" required:"true"`
17
18
Config string `short:"C" long:"config" description:"Swaggman Config File"`
18
19
PostmanBase string `short:"B" long:"basePostmanFile" description:"Basic Postman File"`
19
- Postman string `short:"P" long:"postmanFile" description:"Output Postman File" required:"true" `
20
- OpenAPIFile string `short:"O " long:"openapiFile " description:"Input Swagger File" required:"true "`
20
+ Postman string `short:"P" long:"postmanFile" description:"Output Postman File"`
21
+ XLSXFile string `short:"X " long:"xlsxFile " description:"Output XLSX File"`
21
22
}
22
23
23
24
func (opts * Options ) TrimSpace () {
@@ -34,34 +35,44 @@ func main() {
34
35
log .Fatal (err )
35
36
}
36
37
37
- cfg3 := openapi3postman2.Configuration {}
38
-
39
- if len (opts .Config ) > 0 {
40
- cfg3 , err = openapi3postman2 .ConfigurationReadFile (opts .Config )
41
- if err != nil {
42
- errors .Wrap (err , "openapi3postman2.ConfigurationReadFile" )
43
- log .Fatal (err )
44
- }
45
- }
46
-
47
38
spec , err := openapi3 .ReadFile (opts .OpenAPIFile , true )
48
39
if err != nil {
49
40
log .Fatal (err )
50
41
}
51
- conv := openapi3postman2.Converter {
52
- Configuration : cfg3 ,
53
- OpenAPISpec : spec }
54
42
55
- err = conv .MergeConvert (
56
- opts .OpenAPIFile ,
57
- opts .PostmanBase ,
58
- opts .Postman )
43
+ if len (opts .Postman ) > 0 {
44
+ cfg3 := openapi3postman2.Configuration {}
59
45
60
- if err != nil {
61
- errors .Wrap (err , "swaggman.main << conv.MergeConvert" )
62
- log .Fatal (err )
63
- }
46
+ if len (opts .Config ) > 0 {
47
+ cfg3 , err = openapi3postman2 .ConfigurationReadFile (opts .Config )
48
+ if err != nil {
49
+ errors .Wrap (err , "openapi3postman2.ConfigurationReadFile" )
50
+ log .Fatal (err )
51
+ }
52
+ }
64
53
65
- fmt .Printf ("wrote Postman collection [%s]\n " , opts .Postman )
54
+ conv := openapi3postman2.Converter {
55
+ Configuration : cfg3 ,
56
+ OpenAPISpec : spec }
57
+
58
+ err = conv .MergeConvert (
59
+ opts .OpenAPIFile ,
60
+ opts .PostmanBase ,
61
+ opts .Postman )
62
+
63
+ if err != nil {
64
+ errors .Wrap (err , "swaggman.main << conv.MergeConvert" )
65
+ log .Fatal (err )
66
+ }
67
+
68
+ fmt .Printf ("wrote Postman collection [%s]\n " , opts .Postman )
69
+ }
70
+ if len (opts .XLSXFile ) > 0 {
71
+ sm := openapi3.SpecMore {Spec : spec }
72
+ err := sm .WriteFileXLSX (opts .XLSXFile , nil , nil )
73
+ if err != nil {
74
+ log .Fatal (err )
75
+ }
76
+ }
66
77
fmt .Println ("DONE" )
67
78
}
0 commit comments