从API Explorer(Swagger)中删除嵌套关系
我有 application
具有以下关系的模型:
@belongsTo(() => Ido)
idoId: string;
export interface ApplicationRelations {
ido?: IdoWithRelations;
}
export type ApplicationWithRelations = Application & ApplicationRelations;
application
存储库如下:
export class ApplicationRepository extends DefaultCrudRepository<
Application,
typeof Application.prototype.id,
ApplicationRelations
> {
public readonly user: BelongsToAccessor<
User,
typeof Application.prototype.id
>;
constructor(
@inject('datasources.db') dataSource: DbDataSource,
@repository.getter('UserRepository')
protected userRepositoryGetter: Getter<UserRepository>,
) {
super(Application, dataSource);
this.user = this.createBelongsToAccessorFor('user', userRepositoryGetter);
this.inclusionResolvers.delete('ido');
}
}
以及以下关系 IDO
Modal> Modal> Modal:
@hasMany(() => Application)
applications: Application[];
in post/ido
在Swagger中,我得到了此示例的创建示例:
{
"applications": [
{
"status": "string",
"createdAt": 0,
"idoId": "string",
"userId": "string",
"ido": {
"applications": [
{
"status": "string",
"createdAt": 0,
"idoId": "string",
"userId": "string",
"ido": {
"applications": [
"string"
],
}
是否有任何方法可以从Swagger中删除 IDO
in IDO
的副本关系 ?,否则这并不重要,我可以手动删除第一个应用程序上方的所有字段?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
OpenAPI/Swagger在其余层,这意味着您需要在各自的REST控制器内部查看,这将具有类似的内容:
您可以将其修改为排除关系:
另一种选择是使用
排除
。更多信息可以在API文档中找到:
OpenAPI/Swagger is at the REST layer, which means you'll need to look inside the respective REST Controller, which would have something similar to this:
You can modify it as such to exclude relations:
An alternative is to use
exclude
.More info can be found in the API docs: https://loopback.io/doc/en/lb4/apidocs.repository-json-schema.getjsonschemaref.html