|
|
|
|
@ -50,6 +50,8 @@ type ToolInfo struct {
|
|
|
|
|
Method *string
|
|
|
|
|
SubURL *string
|
|
|
|
|
Operation *Openapi3Operation
|
|
|
|
|
|
|
|
|
|
AgentID *int64
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (t ToolInfo) GetName() string {
|
|
|
|
|
@ -155,7 +157,7 @@ func (t ToolInfo) ToRespAPIParameter() ([]*common.APIParameter, error) {
|
|
|
|
|
location: string(consts.ParamInBody),
|
|
|
|
|
required: required[subParamName],
|
|
|
|
|
}
|
|
|
|
|
apiParam, err := toAPIParameter(paramMeta, prop.Value)
|
|
|
|
|
apiParam, err := t.toAPIParameter(paramMeta, prop.Value)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
@ -204,7 +206,7 @@ func (t ToolInfo) ToReqAPIParameter() ([]*common.APIParameter, error) {
|
|
|
|
|
location: paramVal.In,
|
|
|
|
|
required: paramVal.Required,
|
|
|
|
|
}
|
|
|
|
|
apiParam, err := toAPIParameter(paramMeta, schemaVal)
|
|
|
|
|
apiParam, err := t.toAPIParameter(paramMeta, schemaVal)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
@ -241,7 +243,7 @@ func (t ToolInfo) ToReqAPIParameter() ([]*common.APIParameter, error) {
|
|
|
|
|
location: string(consts.ParamInBody),
|
|
|
|
|
required: required[subParamName],
|
|
|
|
|
}
|
|
|
|
|
apiParam, err := toAPIParameter(paramMeta, prop.Value)
|
|
|
|
|
apiParam, err := t.toAPIParameter(paramMeta, prop.Value)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
@ -255,7 +257,7 @@ func (t ToolInfo) ToReqAPIParameter() ([]*common.APIParameter, error) {
|
|
|
|
|
return params, nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func toAPIParameter(paramMeta paramMetaInfo, sc *openapi3.Schema) (*common.APIParameter, error) {
|
|
|
|
|
func (t ToolInfo) toAPIParameter(paramMeta paramMetaInfo, sc *openapi3.Schema) (*common.APIParameter, error) {
|
|
|
|
|
if sc == nil {
|
|
|
|
|
return nil, fmt.Errorf("schema is required")
|
|
|
|
|
}
|
|
|
|
|
@ -281,7 +283,9 @@ func toAPIParameter(paramMeta paramMetaInfo, sc *openapi3.Schema) (*common.APIPa
|
|
|
|
|
|
|
|
|
|
if sc.Default != nil {
|
|
|
|
|
apiParam.GlobalDefault = ptr.Of(fmt.Sprintf("%v", sc.Default))
|
|
|
|
|
apiParam.LocalDefault = ptr.Of(fmt.Sprintf("%v", sc.Default))
|
|
|
|
|
if t.AgentID != nil {
|
|
|
|
|
apiParam.LocalDefault = ptr.Of(fmt.Sprintf("%v", sc.Default))
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if sc.Format != "" {
|
|
|
|
|
@ -333,7 +337,7 @@ func toAPIParameter(paramMeta paramMetaInfo, sc *openapi3.Schema) (*common.APIPa
|
|
|
|
|
required: required[subParamName],
|
|
|
|
|
location: paramMeta.location,
|
|
|
|
|
}
|
|
|
|
|
subParam, err := toAPIParameter(subMeta, prop.Value)
|
|
|
|
|
subParam, err := t.toAPIParameter(subMeta, prop.Value)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
@ -356,7 +360,7 @@ func toAPIParameter(paramMeta paramMetaInfo, sc *openapi3.Schema) (*common.APIPa
|
|
|
|
|
location: paramMeta.location,
|
|
|
|
|
required: paramMeta.required,
|
|
|
|
|
}
|
|
|
|
|
subParam, err := toAPIParameter(subMeta, item)
|
|
|
|
|
subParam, err := t.toAPIParameter(subMeta, item)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
|