(
schema: StringMap,
path: Ref,
name: string,
isInferred: boolean,
properties: StringMap,
requiredArray: string[]
)
| 266 | } |
| 267 | |
| 268 | function makeClass( |
| 269 | schema: StringMap, |
| 270 | path: Ref, |
| 271 | name: string, |
| 272 | isInferred: boolean, |
| 273 | properties: StringMap, |
| 274 | requiredArray: string[] |
| 275 | ): TypeRef { |
| 276 | const required = Set(requiredArray); |
| 277 | [name, isInferred] = getName(schema, name, isInferred); |
| 278 | const result = typeBuilder.getUniqueClassType(name, isInferred); |
| 279 | const c = assertIsClass(getHopefullyFinishedType(typeBuilder, result)); |
| 280 | setTypeForPath(path, result); |
| 281 | // FIXME: We're using a Map instead of an OrderedMap here because we represent |
| 282 | // the JSON Schema as a JavaScript object, which has no map ordering. Ideally |
| 283 | // we would use a JSON parser that preserves order. |
| 284 | const props = Map(properties).map((propSchema, propName) => { |
| 285 | let t = toType( |
| 286 | checkStringMap(propSchema), |
| 287 | path.push({ kind: PathElementKind.Property, name: propName }), |
| 288 | pluralize.singular(propName), |
| 289 | true |
| 290 | ); |
| 291 | if (!required.has(propName)) { |
| 292 | return typeBuilder.makeNullable(t, propName, true); |
| 293 | } |
| 294 | return t; |
| 295 | }); |
| 296 | c.setProperties(props.toOrderedMap()); |
| 297 | return result; |
| 298 | } |
| 299 | |
| 300 | function makeMap(path: Ref, name: string, additional: StringMap): TypeRef { |
| 301 | let valuesType: TypeRef | undefined = undefined; |
no test coverage detected
searching dependent graphs…