Skip to content

fix: do not add readOnly fields to the requestBody #421

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions pkg/loader/openapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,12 @@ func getOpenAPITools(t *openapi3.T, defaultHost string) ([]types.Tool, error) {
arg.Description = content.Schema.Value.Description
}

// Read Only can not be sent in the request body, so we remove it
for key, property := range arg.Properties {
if property.Value.ReadOnly {
delete(arg.Properties, key)
}
}
// Unfortunately, the request body doesn't contain any good descriptor for it,
// so we just use "requestBodyContent" as the name of the arg.
tool.Parameters.Arguments.Properties["requestBodyContent"] = &openapi3.SchemaRef{Value: arg}
Expand Down