Cannot use different type for HTTP 404.

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

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

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

評価

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

調査の方向性

codegen.rsから始め、issueにある最小限のOpenAPI仕様からクライアントを生成し、200と404のレスポンスがどのように表現されるかに注目してください。生成されたget_state_elementメソッドが404のレスポンスタイプと200のレスポンスタイプを区別できれば完了です。issueでは特定のテストファイルは指定されていません。

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

説明

I want to use progenitor, but generated client uses same response type for HTTP 404 as it has for HTTP 200.

Here is the most simple reproducible spec:

openapi: "3.0.2"
info:
  title: Demo That Triggers It
  version: 0.1.0
  description: "Here you go"
  contact:
    name: Demo
servers:
  - url: http://localhost:12346/
paths:
  /items/{key}:
    get:
      summary: get_state_element
      operationId: get_state_element
      tags: [ "hi-there" ]
      parameters:
        - name: key
          in: path
          required: true
          schema:
            type: string
      responses:
        200:
          $ref: "#/components/responses/StateMapElementResponse2"
        404:
          "$ref": "#/components/responses/NotFound"
components:
  parameters:
    rollup_height:
      name: rollup_height
      in: query
      description: The height of the rollup to query. If not provided, the rollup head is used.
      required: false
      schema:
        type: integer
        minimum: 0
  responses:
    StateMapElementResponse2:
      description: Response containing the value of a `StateMap` element.
      content:
        application/json:
          schema:
            type: object
            properties:
              data:
                type: object
                properties:
                  key:
                    $ref: "#/components/schemas/AnyJsonValue"
                  value:
                    $ref: "#/components/schemas/AnyJsonValue"
                required:
                  - key
                  - value
              meta:
                $ref: "#/components/schemas/AnyJsonValue"
            required:
              - data
    NotFound:
      description: The requested resource was not found.
      content:
        application/json:
          schema:
            type: object
            properties:
              errors:
                type: array
                items:
                  $ref: "#/components/schemas/Error"
              meta:
                $ref: "#/components/schemas/AnyJsonValue"
            required:
              - errors
  schemas:
    AnyJsonValue:
      description: "Any JSON type, including null."
      nullable: true
      oneOf:
        - type: string
          title: "String"
        - type: number
          title: "Number"
        - type: boolean
          title: "Boolean"
        - type: array
          title: "Array"
          items:
            x-stainless-any: true
        - type: object
          title: "Object"
          additionalProperties: true
    Error:
      type: object
      properties:
        status:
          type: integer
          format: int32
          description: HTTP status code related to this error
        title:
          type: string
        details:
          $ref: "#/components/schemas/AnyJsonValue"
      required:
        - status
        - title
        - details

Here is part of the codegen.rs:

impl Client {
    pub async fn get_state_element<'a>(
        &'a self,
        key: &'a str,
    ) -> Result<
        ResponseValue<types::GetStateElementResponse>,
        Error<types::GetStateElementResponse>,
    > { todo!("omitted"); }
}    

I am struggling to find what causes the problem, that Error variant is the same as success.

主要言語
Rust
スター
1k
フォーク
142
平均マージ
19時間 13分
マージ済み PR(30日)
16

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

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

oxidecomputer/progenitor のほかの issue

oxidecomputer/progenitor の issue をすべて見る

似ている issue

Rust の issue をもっと見る

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

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