-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Non-deterministic ordering SecurityDefinitions #316
Copy link
Copy link
Closed
Description
Summary
Currently the order of SecurityDefinitions is not deterministic. SecurityDefinitions is used in below templates.
- https://github.com/deepmap/oapi-codegen/blob/26bb06c00b13ddc6c26107402b8fa398be98ea29/pkg/codegen/templates/wrappers.tmpl#L28-L30
- https://github.com/deepmap/oapi-codegen/blob/950201251f59ac10642a6c332f3926da28d6fceb/pkg/codegen/templates/chi-middleware.tmpl#L41-L43
- https://github.com/deepmap/oapi-codegen/blob/26bb06c00b13ddc6c26107402b8fa398be98ea29/pkg/codegen/templates/templates.gen.go#L168-L170
- https://github.com/deepmap/oapi-codegen/blob/26bb06c00b13ddc6c26107402b8fa398be98ea29/pkg/codegen/templates/templates.gen.go#L879-L881
Reproduction
test.yaml
openapi: 3.0.2
paths:
/a:
get:
oparationId: a
security:
- ApiId: []
ApiKey: []
components:
ApiId:
type: apiKey
in: header
name: X-Api-Id
ApiKey:
type: apiKey
in: header
name: X-Api-Key$ diff -u <(go run ./cmd/oapi-codegen/ test.yaml) <(go run ./cmd/oapi-codegen/ test.yaml)
--- /dev/fd/11 2021-03-17 13:02:42.000000000 +0900
+++ /dev/fd/12 2021-03-17 13:02:42.000000000 +0900
@@ -251,10 +251,10 @@
func (w *ServerInterfaceWrapper) GetA(ctx echo.Context) error {
var err error
- ctx.Set(ApiKeyScopes, []string{""})
-
ctx.Set(ApiIdScopes, []string{""})
+ ctx.Set(ApiKeyScopes, []string{""})
+
// Invoke the callback with all the unmarshalled arguments
err = w.Handler.GetA(ctx)
return errThis problem happens randomly.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels