Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

[Typescript][Angular] Status Code 204: Accept-Content Header

未关闭 适合新手
#9,892 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
62/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
停滞
技术栈
angular, typescript
领域
api, tooling

调研方向

从 modules/openapi-generator/src/main/resources/Javascript/ApiClient.mustache 开始,检查提供的 OpenAPI 声明中如何处理 204 响应的 contentTypes。生成 TypeScript/Angular 客户端并观察请求头。当空的 204 响应不再产生 application/json Accept-Content 请求头时,即表示完成。

由索引模型根据 Issue 内容生成。

描述

Description

Wrong Accept-Content Header for empty response types

Swagger-codegen version

3.0.14

Swagger declaration file content or url
delete:
      operationId: deletePartnerByID
      tags:
        -Partner
      summary: Deletes a communication partner
      parameters:
        - name: deletePartnerByID
          in: path
          description: ID of partner to delete
          required: true
          schema:
            type: integer
            format: int64
      responses:
        204:
          description: OK
        400:
          description: Invalid ID supplied
          content:
            application/json: {}
        404:
          description: Communication partner not found
          content:
            application/json: {}
Command line used for generation

not needed

Steps to reproduce

Follow the Guideline How to make OpenAPI 3.0 to send an empty Accept-Content Header
https://swagger.io/docs/specification/describing-responses/
(In Our Case for HTTP Status code 204)
Test the generated code.
Watch Request Headers
See Accept-Content Header "application/json"

Related issues/PRs
Suggest a fix/enhancement

Fix this code in modules/openapi-generator/src/main/resources/Javascript/ApiClient.mustache

 var contentType = this.jsonPreferredMime(contentTypes);
    if (contentType) {
      if(contentType != 'multipart/form-data') {
        request.type(contentType);
      }
    } else if (!request.header['Content-Type']) {
      request.type('application/json');
    }
主要语言
Mustache
星标
17.8k
派生
6k
PR 合并指标
30 天内没有已合并 PR

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

swagger-api/swagger-codegen 的其他 Issue

查看 swagger-api/swagger-codegen 的全部 Issue

相似的 Issue

更多 Backend & API Design Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。