Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ const complexSchemaParsers = {
},
[SCHEMA_TYPES.COMPLEX_ALL_OF]: (schema) => {
// T1 & T2
const combined = _.map(schema.allOf, complexTypeGetter);
const combined = _.map(schema.allOf.map(s => _.merge({ required: schema.required }, s)), complexTypeGetter);
return checkAndAddNull(
schema,
filterContents(combined, [...JS_EMPTY_TYPES, ...JS_PRIMITIVE_TYPES, TS_KEYWORDS.ANY]).join(
Expand Down
2 changes: 1 addition & 1 deletion tests/generated/v3.0/allof-example.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export interface Pet {
pet_type: string;
}

export type Dog = Pet & { bark?: boolean; breed?: "Dingo" | "Husky" | "Retriever" | "Shepherd" };
export type Dog = Pet & { bark?: boolean; breed: "Dingo" | "Husky" | "Retriever" | "Shepherd" };

export type Cat = Pet & { hunts?: boolean; age?: number };

Expand Down
6 changes: 4 additions & 2 deletions tests/schemas/v3.0/allof-example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ components:
discriminator:
propertyName: pet_type
Dog: # "Dog" is a value for the pet_type property (the discriminator value)
allOf: # Combines the main `Pet` schema with `Dog`-specific properties
required:
- breed
allOf: # Combines the main `Pet` schema with `Dog`-specific properties
- $ref: '#/components/schemas/Pet'
- type: object
# all other properties specific to a `Dog`
Expand All @@ -48,4 +50,4 @@ components:
hunts:
type: boolean
age:
type: integer
type: integer