(t string, ref *openapi3.SchemaRef)
| 478 | } |
| 479 | |
| 480 | func schemaTypeName(t string, ref *openapi3.SchemaRef) string { |
| 481 | s := ref.Value |
| 482 | switch t { |
| 483 | case "array": |
| 484 | if s.Items == nil { |
| 485 | return "list" |
| 486 | } |
| 487 | item := describeSchemaType(s.Items) |
| 488 | if strings.Contains(item, " or ") || strings.Contains(item, ", one of ") { |
| 489 | item = "(" + item + ")" |
| 490 | } |
| 491 | return "list of " + item |
| 492 | case "object": |
| 493 | if name := refName(ref); name != "" { |
| 494 | return "object (" + name + ")" |
| 495 | } |
| 496 | return "object" |
| 497 | case "string": |
| 498 | if s.Format != "" { |
| 499 | return "string (" + s.Format + ")" |
| 500 | } |
| 501 | return "string" |
| 502 | default: |
| 503 | return t |
| 504 | } |
| 505 | } |
| 506 | |
| 507 | // refName is the last part of a schema's $ref, such as simple-user. |
| 508 | func refName(ref *openapi3.SchemaRef) string { |
no test coverage detected