unsupported use case for dynamic node creation

オープン
#270 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

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

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
28/100
issue の種類
機能追加
明瞭さ
説明が足りない
活発さ
静か
技術スタック
javascript
領域
api

調査の方向性

要件、YAML の例、およびこの issue でリンクされている Overlay Specification の議論から始めてください。ソースファイル、テスト、エントリポイントは指定されていません。動的なターゲットノード、nodelist の位置、選択的なコピー、文字列補間がどのように機能すべきかを定義し、期待される出力と元のユースケースに照らして動作を検証してください。

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

説明

re: #150

It seems the copy action only allows copying from known target locations. If more than one nodes exist, there is no way to discriminate which node shall be updated. They are all modified. I believe that's expected behavior.

The copy function fails to support one of the original use cases of copying existing content to a new, dynamic target node.
This can be seen here https://github.com/OAI/Overlay-Specification/issues/121#issuecomment-2887330220

Outlining another use case:

The requirements:

  • find all GET operations
  • create a duplicate of each node with a new suffix '/meta'
  • copy the entire contents of the original node
  • modify the schema node value to point to a new schema for '/meta' responses
  • add new parameters to '/meta' endpoints
Input
openapi: 3.2.0
info:
  title: no meta apis defined
  version: v1
paths:
  /things:
    get:
      responses:
        '200': 
          $ref: '#/components/responses/things_response'
components:
    responses:
      things_response:
        description: OK
        content:
          'application/json':
            schema:
              $ref: '#/components/schemas/things'
    schemas:
      things: {}

Couple things to consider for this copy functionality:

  • the target returns results of the node values but, the spec recommends implementations return the nodelist of result paths(normalized paths) along with the node values. This is implementation defined behavior.
  • there's no way to copy a node value to a new, dynamic node
  • there is also no way to reuse the existing target results to extract the location(s) from the nodelist to create new nodes. The ability to extract the location would be a really nice upgrade
  • there's no way to define which of the nodes from a nodelist are to be copied
  • string interpolation is a touchy subject but, no mechanism exists to modify a string of an existing node value
overlay: 1.1.0
info:
  title: add meta apis
  version: v1
actions:
- target: $.paths[[email protected]]
  description: find any api with a get operation and create new endpoint(s) with a /meta suffix
  update:
      ${target}.location + '/meta'
- target: $.paths[?match(@, '/meta')]
  description: copy the contents of the original get operation to the new meta api.
  copy : $.paths[[email protected]]
- target: $.paths[?match(@, 'meta')].get.responses['200']
  description: fix up the schema reference for meta endpoints
  update:
    $ref: '#/components/responses/${target}_meta'
- target: $.components.parameters
  description: add $filter to components
  update:
    query_filter:
      name: $filter
      description: OData v4 $filter query parameter
      in: query
      required: false
      schema:
        type: string
- target: $.paths[?match(@, 'meta')].get.parameters
  description: add Odata $filter to all /meta endpoints
  update:
    - $ref: '#/components/parameters/query_filter'
Expected output
openapi: 3.2.0
info:
  title: New meta apis defined
  version: v1
paths:
  /things:
    get:
      responses:
        '200': 
          $ref: '#/components/responses/things_response'
 /things/meta:
    get:
     parameters:
      - $ref: '#/components/parameters/query_filter'
      responses:
        '200': 
          $ref: '#/components/responses/things_response_meta'
components:
    responses:
      things_response:
        description: OK
        content:
          'application/json':
            schema:
              $ref: '#/components/schemas/things'
      things_response_meta:
        description: OK
        content:
          'application/json':
            schema:
              $ref: '#/components/schemas/things_meta'

    schemas:
      things: {}
      things_meta: {}
    parameters:
      query_filter:
        name: $filter
        description: OData v4 $filter query parameter
        in: query
        required: false
        schema:
          type: string
主要言語
JavaScript
スター
126
フォーク
38
平均マージ
4日 18時間
マージ済み PR(30日)
9

環境構築

はじめの一歩

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

OAI/Overlay-Specification のほかの issue

OAI/Overlay-Specification の issue をすべて見る

似ている issue

JavaScript の issue をもっと見る

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

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