After upgrading to v2.7.0, generated code fails to compile when the spec uses security at the top level or operation level but does not define the corresponding entry in components/securitySchemes.
Minimal spec to reproduce:
openapi: "3.0.0"
info:
title: Test
version: 1.0.0
security:
- api_key: []
paths:
/hello:
get:
operationId: getHello
responses:
"200":
description: ok
oapi-codegen -generate types,gin,strict-server -o gen.go -package api spec.yaml
Generated output:
const (
Api_keyScopes apiKeyContextKey = "api_key.Scopes"
)
gen.go:20:16: undefined: apiKeyContextKey
The constant references apiKeyContextKey but the type definition type apiKeyContextKey string is never emitted.
Adding components/securitySchemes fixes it -- the type is generated correctly. But the tool should not produce uncompilable code for a spec that was previously accepted, wdyt?
After upgrading to v2.7.0, generated code fails to compile when the spec uses security at the top level or operation level but does not define the corresponding entry in components/securitySchemes.
Minimal spec to reproduce:
Generated output:
The constant references
apiKeyContextKeybut the type definitiontype apiKeyContextKey stringis never emitted.Adding
components/securitySchemesfixes it -- the type is generated correctly. But the tool should not produce uncompilable code for a spec that was previously accepted, wdyt?