42. everything is exported
(no defense against invalid values)
completely relies on encoding/json
(must match how encoding/json works, not necessarily how
the user wants to code)
47. func processOperation(verb string, oper Operation) {
…
}
Currying is, meh…
• You have to remember what to curry
• API signature is no longer standardized
across methods
49. _Should_ be safe
go func() { spec.Info.Title = “foo” }()
go func() { spec.Info.Title = “bar” }()
• Exposing always leaves a way for
users to screw up
61. Data Traversal
• OpenAPI is a tree structure
• You need to traverse through the tree
• … and you need to know the context of
the current node
62. Iterating
• Giving access to raw slices and maps
could mean danger
• Allow access to objects, but no
mutation
63. for pIter := paths.Paths(); pIter.Next(); {
pathName, pathItem := pIter.Item()
for piIter := pathItem.Operations(); piIter.Next(); {
oper := piIter.Item()
}
}
Consistent Iterator API
64. Context
• HTTP verb gives context to Operation
object
• But the data is far from the Operation
object
• Currying is, meh…
65. verb := oper.Verb() // NOT part of OpenAPI spec
Utility Accessors
✓ Creation/Mutation API ensures consistency
with context
✓ No need to curry extra parameters
70. finch% ./oalint -file spec/examples/v2.0/petstore-
expanded.yaml
2018/11/15 09:24:59 failed to parse input: failed to validate
spec: failed to visit Swagger element: swagger field must be
"2.0" (got "2.0.1")
Catches Errors!