Open
Description
When parameter is added as required: false
I would expect it to be non breaking change.
version: github.com/pb33f/libopenapi v0.22.3
code sample:
package main
import (
"fmt"
"testing"
"github.com/pb33f/libopenapi"
)
func TestBreakingChanges(t *testing.T) {
prev := []byte(`openapi: 3.0.3
paths:
test:
get: {}
parameters:
- in: query
name: test
required: true
schema:
type: string
`)
curr := []byte(`openapi: 3.0.3
paths:
test:
get: {}
parameters:
- in: query
name: test
required: true
schema:
type: string
- in: query
name: test2
required: false
schema:
type: string
`)
prevDoc, err := libopenapi.NewDocument(prev)
if err != nil {
panic(fmt.Sprintf("cannot create prev document: %e", err))
}
currDoc, err := libopenapi.NewDocument(curr)
if err != nil {
panic(fmt.Sprintf("cannot create curr document: %e", err))
}
documentChanges, errs := libopenapi.CompareDocuments(prevDoc, currDoc)
if len(errs) > 0 {
for i := range errs {
fmt.Printf("error: %e\n", errs[i])
}
panic(fmt.Sprintf("cannot compare documents: %d errors reported", len(errs)))
}
if documentChanges.TotalBreakingChanges() > 0 {
t.Errorf("expected no breaking changes, but found %d", documentChanges.TotalBreakingChanges())
}
}
Metadata
Metadata
Assignees
Labels
No labels