mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-10-30 02:02:43 +00:00
Fix non-deterministic ordering of 'required' field in OpenAPI spec (#20881)
* Fix non-deterministic ordering of 'required' field in OpenAPI spec Fixes a minor annoyance I discovered whilst comparing before and after OpenAPI specs whilst working on hashicorp/vault-client-go#180. Sort the entries in a JSON array which has set semantics, after we construct it by iterating a map (non-deterministic ordering). * changelog
This commit is contained in:
3
changelog/20881.txt
Normal file
3
changelog/20881.txt
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
```release-note:improvement
|
||||||
|
sdk/framework: Fix non-deterministic ordering of 'required' fields in OpenAPI spec
|
||||||
|
```
|
||||||
@@ -383,6 +383,10 @@ func documentPath(p *Path, specialPaths *logical.Paths, requestResponsePrefix st
|
|||||||
s.Properties[name] = &p
|
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
|
// If examples were given, use the first one as the sample
|
||||||
// of this schema.
|
// of this schema.
|
||||||
if len(props.Examples) > 0 {
|
if len(props.Examples) > 0 {
|
||||||
|
|||||||
Reference in New Issue
Block a user