Skip to content

Commit 79ffa1c

Browse files
committed
update docs and remove unnecessary marshal and unmarshal
Signed-off-by: Grant Linville <[email protected]>
1 parent 11a0301 commit 79ffa1c

File tree

2 files changed

+4
-28
lines changed

2 files changed

+4
-28
lines changed

docs/docs/03-tools/03-openapi.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,3 @@ In OpenAPI definitions, request bodies are described with a MIME type. Currently
6464

6565
GPTScript will return an error when parsing the OpenAPI definition if it finds a request body that does not specify
6666
at least one of these supported MIME types.
67-
68-
## Limitations
69-
70-
In addition to the limitations mentioned above, there are some portions of JSONSchema that are not implemented
71-
in GPTScript yet, such as `oneOf`, `anyOf`, and `allOf`. These will likely be implemented in the future.
72-
There may be some other aspects of OpenAPI definitions that are not yet handled by GPTScript.

pkg/loader/openapi.go

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -84,23 +84,14 @@ func getOpenAPITools(t *openapi3.T) ([]types.Tool, error) {
8484

8585
// Handle query, path, and header parameters
8686
for _, param := range operation.Parameters {
87-
// Marshal the param's schema to a string, and then into our JSONSchema struct
88-
raw, err := param.Value.Schema.Value.MarshalJSON()
89-
if err != nil {
90-
return nil, err
91-
}
92-
93-
arg := openapi3.Schema{}
94-
if err := json.Unmarshal(raw, &arg); err != nil {
95-
return nil, err
96-
}
87+
arg := param.Value.Schema.Value
9788

9889
if arg.Description == "" {
9990
arg.Description = param.Value.Description
10091
}
10192

10293
// Add the new arg to the tool's arguments
103-
tool.Parameters.Arguments.Properties[param.Value.Name] = &openapi3.SchemaRef{Value: &arg}
94+
tool.Parameters.Arguments.Properties[param.Value.Name] = &openapi3.SchemaRef{Value: arg}
10495

10596
// Check whether it is required
10697
if param.Value.Required {
@@ -135,23 +126,14 @@ func getOpenAPITools(t *openapi3.T) ([]types.Tool, error) {
135126
}
136127
bodyMIME = mime
137128

138-
raw, err := content.Schema.Value.MarshalJSON()
139-
if err != nil {
140-
return nil, err
141-
}
142-
143-
arg := openapi3.Schema{}
144-
if err := json.Unmarshal(raw, &arg); err != nil {
145-
return nil, err
146-
}
147-
129+
arg := content.Schema.Value
148130
if arg.Description == "" {
149131
arg.Description = content.Schema.Value.Description
150132
}
151133

152134
// Unfortunately, the request body doesn't contain any good descriptor for it,
153135
// so we just use "requestBodyContent" as the name of the arg.
154-
tool.Parameters.Arguments.Properties["requestBodyContent"] = &openapi3.SchemaRef{Value: &arg}
136+
tool.Parameters.Arguments.Properties["requestBodyContent"] = &openapi3.SchemaRef{Value: arg}
155137
break
156138
}
157139

0 commit comments

Comments
 (0)