(name string)
| 530 | } |
| 531 | |
| 532 | func (idx *OpenAPIIndex) getSchemaByName(name string) []PropertyInfo { |
| 533 | schemaProxy, ok := idx.doc.Model.Components.Schemas.Get(name) |
| 534 | if !ok || schemaProxy == nil { |
| 535 | return nil |
| 536 | } |
| 537 | |
| 538 | schema := schemaProxy.Schema() |
| 539 | if schema == nil { |
| 540 | return nil |
| 541 | } |
| 542 | |
| 543 | // Handle enum types |
| 544 | if len(schema.Enum) > 0 { |
| 545 | var enumValues []string |
| 546 | for _, v := range schema.Enum { |
| 547 | if v != nil && v.Value != "" { |
| 548 | enumValues = append(enumValues, v.Value) |
| 549 | } |
| 550 | } |
| 551 | return []PropertyInfo{{ |
| 552 | Name: "enum", |
| 553 | Type: "string", |
| 554 | Description: strings.Join(enumValues, ", "), |
| 555 | }} |
| 556 | } |
| 557 | |
| 558 | if schema.Properties == nil { |
| 559 | return nil |
| 560 | } |
| 561 | |
| 562 | var props []PropertyInfo |
| 563 | requiredSet := make(map[string]bool) |
| 564 | for _, r := range schema.Required { |
| 565 | requiredSet[r] = true |
| 566 | } |
| 567 | |
| 568 | for pair := schema.Properties.First(); pair != nil; pair = pair.Next() { |
| 569 | propName := pair.Key() |
| 570 | prop := pair.Value() |
| 571 | |
| 572 | propType, desc := extractPropertyTypeAndDesc(prop) |
| 573 | |
| 574 | props = append(props, PropertyInfo{ |
| 575 | Name: propName, |
| 576 | Type: propType, |
| 577 | Description: desc, |
| 578 | Required: requiredSet[propName], |
| 579 | }) |
| 580 | } |
| 581 | |
| 582 | slices.SortFunc(props, func(a, b PropertyInfo) int { |
| 583 | return strings.Compare(a.Name, b.Name) |
| 584 | }) |
| 585 | |
| 586 | return props |
| 587 | } |
no test coverage detected