Closed3

【swagger-merger】allOfが使えない

やむやむ

allOfが使えないのか、エラーになる。

Error: Invalid JSON pointer: ../../schemas/error-response.yml#/error_response_500
やむやむ

allOfを使用しない書き方

allOfを使用しない書き方。

Before

  responses:
    '500':
      allOf:
        - $ref: '../../responses/error-response.yml#/error_response_500'
      description: 500 Error

After

  responses:
    '500':
      description: 500 Error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/error_response'
          examples:
            default:
              $ref: '#/components/examples/error_response_500'

responsesディレクトリを作成してそこにresponseを定義して呼び出し、descriptionを上書きする書き方にしていたが、この書き方だとdescriptionは上書きされない。

そのため、schemasディレクトリにschemaを定義して上書きしない書き方に変更した。

さらに、exampleはexampleだとうまく表示されないためexamplesにしてタイトルをテキトーにdefaultなどにしてvalue以降を$ref参照で呼び出す。

やむやむ

mergerを使用しない場合は、allOfを使用できる。
書き方が微妙に違うと混乱するから同じ書き方できるようにしてほしいなぁ。

このスクラップは27日前にクローズされました