(r Registry, t reflect.Type)
| 198 | } |
| 199 | |
| 200 | func multiPartFormFileSchema(r Registry, t reflect.Type) *Schema { |
| 201 | nFields := t.NumField() |
| 202 | schema := &Schema{ |
| 203 | Type: "object", |
| 204 | Properties: make(map[string]*Schema, nFields), |
| 205 | requiredMap: make(map[string]bool, nFields), |
| 206 | } |
| 207 | requiredFields := make([]string, 0, nFields) |
| 208 | for i := range nFields { |
| 209 | f := t.Field(i) |
| 210 | name := formDataFieldName(f) |
| 211 | |
| 212 | switch { |
| 213 | case f.Type == reflect.TypeFor[FormFile](): |
| 214 | schema.Properties[name] = multiPartFileSchema(f) |
| 215 | case f.Type == reflect.TypeFor[[]FormFile](): |
| 216 | schema.Properties[name] = &Schema{ |
| 217 | Type: "array", |
| 218 | Items: multiPartFileSchema(f), |
| 219 | } |
| 220 | default: |
| 221 | schema.Properties[name] = SchemaFromField(r, f, name) |
| 222 | |
| 223 | // Should we panic if [T] struct defines fields with unsupported types? |
| 224 | } |
| 225 | |
| 226 | fieldRequired := !getConfig[registryConfig](r).FieldsOptionalByDefault |
| 227 | |
| 228 | if _, ok := f.Tag.Lookup("required"); ok { |
| 229 | fieldRequired = boolTag(f, "required", false) |
| 230 | } |
| 231 | |
| 232 | if fieldRequired { |
| 233 | requiredFields = append(requiredFields, name) |
| 234 | schema.requiredMap[name] = true |
| 235 | } |
| 236 | } |
| 237 | schema.Required = requiredFields |
| 238 | return schema |
| 239 | } |
| 240 | |
| 241 | func multiPartFileSchema(f reflect.StructField) *Schema { |
| 242 | return &Schema{ |
no test coverage detected
searching dependent graphs…