Skip to content
Merged
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
46 changes: 46 additions & 0 deletions docs/site/decorators/Decorators_openapi.md
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,52 @@ export class SomeController {
}
```

#### anyOf, allOf, oneOf, not

The `x-ts-type` extention is also valid as a value in `allOf`, `anyOf`, `oneOf`,
and `not` schema keys.

```ts
@model
class FooModel extends Model {
@property()
foo: string;
}

@model
class BarModel extends Model {
@property()
bar: string;
}

@model
class BazModel extends Model {
@property()
baz: string;
}

class MyController {
@get('/some-value', {
responses: {
'200': {
description: 'returns a union of two values',
content: {
'application/json': {
schema: {
not: {'x-ts-type': BazModel},
allOf: [{'x-ts-type': FooModel}, {'x-ts-type': BarModel}],
},
},
},
},
},
})
getSomeValue() {
return {foo: 'foo', bar: 'bar'};
}
}
```

When the OpenAPI spec is generated, the `xs-ts-type` is mapped to
`{$ref: '#/components/schemas/MyModel'}` and a corresponding schema is added to
`components.schemas.MyModel` of the spec.
Expand Down