Cannot use different type for HTTP 404.

Đang mở
#928 2 bình luận 1 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
35/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
rust

Hướng nghiên cứu

Bắt đầu với codegen.rs và tạo một client từ đặc tả OpenAPI tối thiểu trong issue, tập trung vào cách các response 200 và 404 được biểu diễn. Công việc được xem là hoàn tất khi phương thức get_state_element được tạo phân biệt kiểu response 404 với kiểu response 200; issue không nêu tên file test cụ thể nào.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
Rust
Star
1k
Fork
142
Merge trung bình
19 giờ 13 phút
Pull request đã merge (30 ngày)
16

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của oxidecomputer/progenitor

Tất cả issue của oxidecomputer/progenitor

Issue tương tự

Thêm issue về Rust

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.