-
Notifications
You must be signed in to change notification settings - Fork 28
/
convert.go
66 lines (55 loc) · 1.62 KB
/
convert.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package main
import (
"fmt"
"log"
"github.com/grokify/spectrum/openapi2/openapi2postman2"
"github.com/grokify/spectrum/openapi3"
"github.com/grokify/spectrum/postman2"
"github.com/jessevdk/go-flags"
)
// Convert yaml2json: https://github.com/bronze1man/yaml2json ... yaml2json_darwin_amd64
type Options struct {
PostmanBase string `short:"b" long:"base" description:"Basic Postman File"`
Postman string `short:"p" long:"postman" description:"Output Postman File" required:"true"`
OpenAPISpec string `short:"s" long:"openapispec" description:"Input OpenAPI Spec File" required:"true"`
}
func main() {
var opts Options
_, err := flags.Parse(&opts)
if err != nil {
log.Fatal(err)
}
if 1 == 1 {
spec, err := openapi3.ReadFile(opts.OpenAPISpec, true)
if err != nil {
log.Fatal(err)
}
sm := openapi3.SpecMore{Spec: spec}
if 1 == 1 {
err := sm.SchemaPropertiesWithoutDescriptionsWriteFile("rc-platform.yml.schema-properties_missing-descriptions.txt")
if err != nil {
log.Fatal(err)
}
}
if 1 == 1 {
err := sm.OperationParametersWithoutDescriptionsWriteFile("rc-platform.yml.op-params_missing-descriptions.txt")
if err != nil {
log.Fatal(err)
}
}
panic("ZZZ")
}
cfg := openapi2postman2.Configuration{
PostmanURLBase: "{{RINGCENTRAL_SERVER_URL}}",
PostmanHeaders: []postman2.Header{{
Key: "Authorization",
Value: "Bearer {{my_access_token}}"}}}
conv := openapi2postman2.NewConverter(cfg)
err = conv.MergeConvert(opts.OpenAPISpec, opts.PostmanBase, opts.Postman)
if err != nil {
log.Fatal(err)
} else {
fmt.Printf("Wrote %v\n", opts.Postman)
}
fmt.Println("DONE")
}