You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This isn't a bug - I'm trying to figure out how to add a request body parameter to an operation
I have an openapi spec file, but one of the operations does not have a body parameter for a POST and I was trying to be smart and add it in processing the json with kin
A cunning and daring plan. With 2 small flaws
a) I don't know Go
b) I don't know Go
I have tried to work my way through tests, sample code and even lowered myself to use Gemini and Chat Gtp (bloody useless) so I am throwing myself at the mercy of this community
the payload is a json object with any number of keys and a value
{"foo":"bar","baz":"abc"}
etc
I have got so far
func addBodyParameter(operation *openapi3.Operation) {
payloadSchema := &openapi3.SchemaRef{Value: &openapi3.Schema{Type: &openapi3.Types{"object"},
AdditionalProperties: &openapi3.Schema{Type: &openapi3.Types{"string"}},
}}
mediaType := &openapi3.MediaType{
Schema: payloadSchema,
}
requestBody := &openapi3.RequestBody{
Required: true,
Content: openapi3.Content{
"application/json": mediaType,
},
}
operation.RequestBody = &openapi3.RequestBodyRef{
Value: requestBody,
}
log.Println("xx", payloadSchema)
}
for path, pathItem := range doc.Paths.Map() { // doc.Paths is of type *openapi3.Paths
for _, operation := range []*openapi3.Operation{
pathItem.Get, pathItem.Post, pathItem.Put, pathItem.Delete, pathItem.Patch,
} {
if operation.OperationID == "cubbyhole-write" {
addBodyParameter(operation)
}
I think that I just can;t find the right syntax for payloadSchema
Would appreciate any help
The text was updated successfully, but these errors were encountered:
This isn't a bug - I'm trying to figure out how to add a request body parameter to an operation
I have an openapi spec file, but one of the operations does not have a body parameter for a POST and I was trying to be smart and add it in processing the json with kin
A cunning and daring plan. With 2 small flaws
a) I don't know Go
b) I don't know Go
I have tried to work my way through tests, sample code and even lowered myself to use Gemini and Chat Gtp (bloody useless) so I am throwing myself at the mercy of this community
the payload is a json object with any number of keys and a value
{"foo":"bar","baz":"abc"}
etc
I have got so far
I think that I just can;t find the right syntax for payloadSchema
Would appreciate any help
The text was updated successfully, but these errors were encountered: