this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

add tests and fix nullable params issue

+65 -16
+37 -16
atproto/lexicon/language.go
··· 83 83 } 84 84 s.Inner = v 85 85 case SchemaQuery: 86 - for i, val := range v.Parameters.Properties { 87 - val.SetBase(base) 88 - v.Parameters.Properties[i] = val 86 + if v.Parameters != nil { 87 + for i, val := range v.Parameters.Properties { 88 + val.SetBase(base) 89 + v.Parameters.Properties[i] = val 90 + } 89 91 } 90 92 if v.Output != nil && v.Output.Schema != nil { 91 93 v.Output.Schema.SetBase(base) 92 94 } 93 95 s.Inner = v 94 96 case SchemaProcedure: 95 - for i, val := range v.Parameters.Properties { 96 - val.SetBase(base) 97 - v.Parameters.Properties[i] = val 97 + if v.Parameters != nil { 98 + for i, val := range v.Parameters.Properties { 99 + val.SetBase(base) 100 + v.Parameters.Properties[i] = val 101 + } 98 102 } 99 103 if v.Input != nil && v.Input.Schema != nil { 100 104 v.Input.Schema.SetBase(base) ··· 104 108 } 105 109 s.Inner = v 106 110 case SchemaSubscription: 107 - for i, val := range v.Parameters.Properties { 108 - val.SetBase(base) 109 - v.Parameters.Properties[i] = val 111 + if v.Parameters != nil { 112 + for i, val := range v.Parameters.Properties { 113 + val.SetBase(base) 114 + v.Parameters.Properties[i] = val 115 + } 110 116 } 111 117 if v.Message != nil { 112 118 v.Message.Schema.SetBase(base) ··· 326 332 type SchemaQuery struct { 327 333 Type string `json:"type"` // "query" 328 334 Description *string `json:"description,omitempty"` 329 - Parameters SchemaParams `json:"parameters"` 330 - Output *SchemaBody `json:"output"` 335 + Parameters *SchemaParams `json:"parameters"` // optional 336 + Output *SchemaBody `json:"output"` // optional 331 337 Errors []SchemaError `json:"errors,omitempty"` // optional 332 338 } 333 339 ··· 337 343 return err 338 344 } 339 345 } 346 + if s.Parameters != nil { 347 + if err := s.Parameters.CheckSchema(); err != nil { 348 + return err 349 + } 350 + } 340 351 for _, e := range s.Errors { 341 352 if err := e.CheckSchema(); err != nil { 342 353 return err 343 354 } 344 355 } 345 - return s.Parameters.CheckSchema() 356 + return nil 346 357 } 347 358 348 359 type SchemaProcedure struct { 349 360 Type string `json:"type"` // "procedure" 350 361 Description *string `json:"description,omitempty"` 351 - Parameters SchemaParams `json:"parameters"` 362 + Parameters *SchemaParams `json:"parameters"` // optional 352 363 Output *SchemaBody `json:"output"` // optional 353 364 Errors []SchemaError `json:"errors,omitempty"` // optional 354 365 Input *SchemaBody `json:"input"` // optional ··· 365 376 return err 366 377 } 367 378 } 379 + if s.Parameters != nil { 380 + if err := s.Parameters.CheckSchema(); err != nil { 381 + return err 382 + } 383 + } 368 384 for _, e := range s.Errors { 369 385 if err := e.CheckSchema(); err != nil { 370 386 return err 371 387 } 372 388 } 373 - return s.Parameters.CheckSchema() 389 + return nil 374 390 } 375 391 376 392 type SchemaSubscription struct { 377 393 Type string `json:"type"` // "subscription" 378 394 Description *string `json:"description,omitempty"` 379 - Parameters SchemaParams `json:"parameters"` 395 + Parameters *SchemaParams `json:"parameters"` // optional 380 396 Message *SchemaMessage `json:"message,omitempty"` // TODO(specs): is this really optional? 381 397 } 382 398 ··· 386 402 return err 387 403 } 388 404 } 389 - return s.Parameters.CheckSchema() 405 + if s.Parameters != nil { 406 + if err := s.Parameters.CheckSchema(); err != nil { 407 + return err 408 + } 409 + } 410 + return nil 390 411 } 391 412 392 413 type SchemaPermissionSet struct {
+16
atproto/lexicon/testdata/catalog/minimal-procedure.json
··· 1 + { 2 + "lexicon": 1, 3 + "id": "example.lexicon.minimal.procedure", 4 + "description": "demonstrates lexicon features for the procedure type", 5 + "defs": { 6 + "main": { 7 + "type": "procedure", 8 + "input": { 9 + "encoding": "application/json", 10 + "schema": { 11 + "type": "object" 12 + } 13 + } 14 + } 15 + } 16 + }
+12
atproto/lexicon/testdata/catalog/minimal-query.json
··· 1 + { 2 + "lexicon": 1, 3 + "id": "example.lexicon.minimal.query", 4 + "revision": 1, 5 + "description": "exercizes many lexicon features for the query type", 6 + "defs": { 7 + "main": { 8 + "type": "query", 9 + "description": "a query type" 10 + } 11 + } 12 + }