diff --git a/changelog/20881.txt b/changelog/20881.txt new file mode 100644 index 000000000000..fd3e6d5fa44f --- /dev/null +++ b/changelog/20881.txt @@ -0,0 +1,3 @@ +```release-note:improvement +sdk/framework: Fix non-deterministic ordering of 'required' fields in OpenAPI spec +``` diff --git a/sdk/framework/openapi.go b/sdk/framework/openapi.go index d69e0b83e69d..e43c5ff89eea 100644 --- a/sdk/framework/openapi.go +++ b/sdk/framework/openapi.go @@ -373,6 +373,10 @@ func documentPath(p *Path, specialPaths *logical.Paths, requestResponsePrefix st s.Properties[name] = &p } + // Make the ordering deterministic, so that the generated OpenAPI spec document, observed over several + // versions, doesn't contain spurious non-semantic changes. + sort.Strings(s.Required) + // If examples were given, use the first one as the sample // of this schema. if len(props.Examples) > 0 {