Skip to content

Commit

Permalink
fix: show empty jsonSchema for verbs with no req (#1725)
Browse files Browse the repository at this point in the history
  • Loading branch information
wesbillman authored Jun 10, 2024
1 parent a34562b commit aaebb97
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
20 changes: 11 additions & 9 deletions backend/controller/console.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,16 +99,18 @@ func (c *ConsoleService) GetModules(ctx context.Context, req *connect.Request[pb
v := decl.ToProto().(*schemapb.Verb)
verbSchema := schema.VerbFromProto(v)
var jsonRequestSchema string
if requestData, ok := verbSchema.Request.(*schema.Ref); ok {
jsonSchema, err := schema.DataToJSONSchema(sch, *requestData)
if err != nil {
return nil, err
if verbSchema.Request == nil {
if requestData, ok := verbSchema.Request.(*schema.Ref); ok {
jsonSchema, err := schema.DataToJSONSchema(sch, *requestData)
if err != nil {
return nil, err
}
jsonData, err := json.MarshalIndent(jsonSchema, "", " ")
if err != nil {
return nil, err
}
jsonRequestSchema = string(jsonData)
}
jsonData, err := json.MarshalIndent(jsonSchema, "", " ")
if err != nil {
return nil, err
}
jsonRequestSchema = string(jsonData)
}

schemaString, err := verbSchemaString(sch, decl)
Expand Down
4 changes: 4 additions & 0 deletions frontend/src/features/verbs/verb.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ const processJsonValue = (value: JsonValue): JsonValue =>{

// eslint-disable-next-line @typescript-eslint/no-explicit-any
export const simpleJsonSchema = (verb: Verb): any => {
if (!verb.jsonRequestSchema) {
return {}
}

let schema = JSON.parse(verb.jsonRequestSchema)

if (schema.properties && isHttpIngress(verb)) {
Expand Down

0 comments on commit aaebb97

Please sign in to comment.