forked from ogen-go/ogen
-
Notifications
You must be signed in to change notification settings - Fork 0
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
When generating code from a valid OpenAPI spec, ogen produces a type switch with duplicate case statements, resulting in Go compilation error.
Reproduction
Using spec from: https://github.com/gojitsu/jitsu
ogen --target /tmp/test --clean carriers/jitsu/specs/openapi.yaml
cd /tmp/test && go mod init test && go mod tidy && go build ./...Error
./oas_response_encoders_gen.go:42:7: duplicate case *NewShipmentResponseStatusCode in type switch
./oas_response_encoders_gen.go:17:7: previous case
Generated Code (oas_response_encoders_gen.go)
func encodeNewShipmentResponse(response NewShipmentRes, w http.ResponseWriter, span trace.Span) error {
switch v := response.(type) {
case *NewShipmentResponseStatusCode: // Line 17
// ...
// ... other cases ...
case *NewShipmentResponseStatusCode: // Line 42 - DUPLICATE!
// ...
}
}Expected
Generated Go code should compile without errors
Actual
Duplicate case statements in generated switch statement - Go compilation fails
Impact
Valid OpenAPI 3.0.1 spec cannot generate working Go client. This is a critical bug as the spec is valid but codegen produces invalid Go.
Environment
- ogen version: v1.16.0
- Go version: 1.21+
- OS: macOS
Context
Discovered while validating 20 carrier/logistics API specs. This appears to be related to how ogen generates response encoders when multiple response status codes share the same schema type.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working