Can this issue be reproduced with the latest version?
Yes
What did you do?
OpenAPI yaml:
openapi: 3.0.3
info:
title: Awesome GO API
version: 1.0.0
description: Actual example use cases for a curated list of golang api generator libraries
servers:
- url: http://localhost:8080
description: dev instance
paths:
/error:
get:
summary: Get an error
description: Responds with an error
operationId: get-error
responses:
400:
description: Bad request
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
components:
schemas:
Error:
description: An API error
type: object
properties:
title:
description: A short, human-readable summary of the problem type. This value should not change between occurrences of the error.
example: Bad Request
type: string
details:
description: A human-readable explanation specific to this occurrence of the problem.
example: Property foo is required but is missing.
type: string
properties:
description: Optional map of properties
nullable: true
type: object
Server:
package main
import (
"context"
"fmt"
"net/http"
api "github.com/veqryn/awesome-go-api/openapiv3/ogen/gen"
)
var _ api.Handler = &App{}
type App struct {
// server.Unimplemented // Can be used to future proof against new api endpoints
}
func (s *App) GetError(ctx context.Context) (*api.Error, error) {
respErr := &api.Error{
Title: api.NewOptString("Bad Request"),
Details: api.NewOptString("This is an example error"),
Properties: api.NewOptErrorProperties(&api.ErrorProperties{}),
}
return respErr, nil
}
func main() {
app := &App{}
server, err := api.NewServer(app)
if err != nil {
panic(err)
}
http.ListenAndServe(":8080", server)
}
What version of ogen are you using?
v1.4.0
Can this issue be reproduced with the latest version?
Yes
What did you do?
OpenAPI yaml:
Server:
Client:
Result:
If I manually curl the server, I get this back, which is expected:
What did you expect to see?
Everything work fine.
What did you see instead?
An error returned because ogen or its json dependency is unable to unmarshall an empty json object into a simple golang struct.