Skip to content

net/goai: I want to customize the response 500 content #3747

@ivothgle

Description

@ivothgle

Go version

go1.22

GoFrame version

2.7.0

Can this bug be reproduced with the latest release?

Option Yes

What did you do?

	req.Server.GetOpenApi().Add(goai.AddInput{
		Object: req.Server.GetOpenApi().Config.CommonResponse,
	})
	req.Server.GetOpenApi().Components.Responses = goai.Responses{
		"InternalServerError": goai.ResponseRef{
			Value: &goai.Response{
				Description: "InternalServerError",
				Content: map[string]goai.MediaType{
					"application/json": {Schema: &goai.SchemaRef{Ref: "model.DefaultHandlerResponse"}},
				},
			},
		},
	}

I want to customize the response 500 content,

output
"500": {
"$ref": "#/components/schemas/InternalServerError"
}
He should be "#/components/responses/InternalServerError", see https://swagger.io/docs/specification/describing-responses/

What did you see happen?

It is not possible to customize the reference response structure in OpenAI because its prefix is ​​always fixed

code is:

return []byte(fmt.Sprintf(`{"$ref":"#/components/schemas/%s"}`, ref))

What did you expect to see?

He should be "#/components/responses/InternalServerError", see https://swagger.io/docs/specification/describing-responses/

Metadata

Metadata

Assignees

No one assigned

    Labels

    discussWe need discuss to make decision.enhancementhelp wantedplannedThis issue/proposal is planned into our next steps.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions