Skip to content

Commit 30fe8fb

Browse files
docs: doc and link updates
1 parent 87a46b1 commit 30fe8fb

File tree

3 files changed

+25
-23
lines changed

3 files changed

+25
-23
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22

33
The Speakeasy OpenAPI module provides a set of packages and tools for working with OpenAPI Specification documents.
44

5+
Documentation for the packages can be found in the [GoDoc documentation.](https://pkg.go.dev/github.com/speakeasy-api/openapi)
6+
57
## Main Packages
68

7-
### [arazzo](./arazzo/README.md)
9+
### [arazzo](./arazzo)
810

911
The `arazzo` package provides an API for working with Arazzo documents including reading, creating, mutating, walking and validating them.

arazzo/README.md

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,35 @@ import (
2222
func main() {
2323
ctx := context.Background()
2424

25-
f, err := os.Open("arazzo.yaml")
25+
r, err := os.Open("testdata/speakeasybar.arazzo.yaml")
2626
if err != nil {
2727
panic(err)
2828
}
29+
defer r.Close()
2930

30-
arazzo, validationErrs, err := arazzo.Unmarshal(ctx, f)
31+
// Unmarshal the Arazzo document which will also validate it against the Arazzo Specification
32+
a, validationErrs, err := arazzo.Unmarshal(ctx, r)
3133
if err != nil {
3234
panic(err)
3335
}
3436

35-
fmt.Printf("%+v\n", arazzo)
36-
fmt.Printf("%+v\n", validationErrs)
37+
// Validation errors are returned separately from any errors that block the document from being unmarshalled
38+
// allowing an invalid document to be mutated and fixed before being marshalled again
39+
for _, err := range validationErrs {
40+
fmt.Println(err.Error())
41+
}
42+
43+
// Mutate the document by just modifying the returned Arazzo object
44+
a.Info.Title = "Speakeasy Bar Workflows"
45+
46+
buf := bytes.NewBuffer([]byte{})
47+
48+
// Marshal the document to a writer
49+
if err := arazzo.Marshal(ctx, a, buf); err != nil {
50+
panic(err)
51+
}
52+
53+
fmt.Println(buf.String())
3754
}
3855
```
3956

arazzo/arazzo_examples_test.go

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"github.com/speakeasy-api/openapi/pointer"
1111
)
1212

13+
// The below examples should be copied into the README.md file if every changed TODO: automate this
1314
func Example_readAndMutate() {
1415
ctx := context.Background()
1516

@@ -44,24 +45,6 @@ func Example_readAndMutate() {
4445
fmt.Println(buf.String())
4546
}
4647

47-
// The below examples should be copied into the README.md file if every changed TODO: automate this
48-
func Example_reading() {
49-
ctx := context.Background()
50-
51-
f, err := os.Open("arazzo.yaml")
52-
if err != nil {
53-
panic(err)
54-
}
55-
56-
arazzo, validationErrs, err := arazzo.Unmarshal(ctx, f)
57-
if err != nil {
58-
panic(err)
59-
}
60-
61-
fmt.Printf("%+v\n", arazzo)
62-
fmt.Printf("%+v\n", validationErrs)
63-
}
64-
6548
func Example_creating() {
6649
ctx := context.Background()
6750

0 commit comments

Comments
 (0)