loopbackio / loopbackio/loopback-next

Loopback 4: Exclude issue in hasone relations

オープン
#7,517 コメント 4 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

feature help wanted OpenAPI
主要言語
TypeScript
スター
5.1k
フォーク
1.1k
平均マージ
2日 21時間
マージ済み PR(30日)
27

説明

Hello all,

I have looked for a solution to that, but I see nothing in the documentation and in the forums. I start to think that it is not possible to do, or that it is some kind of issue.

In a schema, It is possible to exclude a field how comes from a @hasone relation?

Captura de pantalla 2021-05-29 a las 10 00 18

I have tried several things. The more weird is that if in the exclude you indicate a property who appears in the model A and in the hasOne relation model, in the schema, for both models, the property is excluded. :

 @patch('/user/{id}', {
    responses: {
      '204': {
        description: 'Update all the information related with the user',
      },
    },
  })
  @authenticate('jwt', { required: [PermissionKey.UpdateOwnUser] })
  async updateById(
    @param.path.string('id') id: string,
    @requestBody({
      content: {
        'application/json': {
          schema: getModelSchemaRef(UserFeatures, {
            includeRelations: true,
            exclude: ['idUser', 'stripeCustomerId', 'userIAM.permissions'],
          }),


        },
      },
    })

The problem is that the exclude doesnt´work for the hasOne relation: exclude: ['idUser', 'stripeCustomerId'] --> OK exclude: ['permissions'] --> Fails

Any idea of how to exclude a field of the "hasOne Relation model"?

Thanks in advance

Best

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

getModelSchemaRef と issue に示されている @requestBody スキーマから始め、hasOne リレーションに対して includeRelations と exclude がどのように解釈されるかに焦点を当てます。exclude: ['permissions']; を使った例を再現します。既存のトップレベルの除外を変更せずに、ネストされたリレーションフィールドが除外されれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
typescript
領域
api
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。