GetSchema returns the schema properties for a component schema by name. Supports both full name (bytebase.v1.Instance) and short name (Instance).
(name string)
| 509 | // GetSchema returns the schema properties for a component schema by name. |
| 510 | // Supports both full name (bytebase.v1.Instance) and short name (Instance). |
| 511 | func (idx *OpenAPIIndex) GetSchema(name string) ([]PropertyInfo, bool) { |
| 512 | if idx.doc.Model.Components == nil || idx.doc.Model.Components.Schemas == nil { |
| 513 | return nil, false |
| 514 | } |
| 515 | |
| 516 | // Try exact name first |
| 517 | if props := idx.getSchemaByName(name); props != nil { |
| 518 | return props, true |
| 519 | } |
| 520 | |
| 521 | // Try with bytebase.v1. prefix |
| 522 | if !strings.HasPrefix(name, "bytebase.v1.") { |
| 523 | fullName := "bytebase.v1." + name |
| 524 | if props := idx.getSchemaByName(fullName); props != nil { |
| 525 | return props, true |
| 526 | } |
| 527 | } |
| 528 | |
| 529 | return nil, false |
| 530 | } |
| 531 | |
| 532 | func (idx *OpenAPIIndex) getSchemaByName(name string) []PropertyInfo { |
| 533 | schemaProxy, ok := idx.doc.Model.Components.Schemas.Get(name) |
no test coverage detected