Skip to content
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

fix: show empty jsonSchema for verbs with no req #1725

Merged
merged 1 commit into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
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
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
Loading