Swagger.json生成的大小写不正确的“类型”:“字符串”

问题描述

在故障排除this problem中,我们发现swagger.json包含错误的大小写

“类型”:“字符串”

生成代码

for step

我有以下ISchemaFilter

  "/api/FrameLookUp": {
      "post": {
        "tags": [
          "Frame"
        ],"operationId": "FrameLookup","consumes": [
          "application/json-patch+json","application/json","text/json","application/*+json"
        ],"produces": [
          "application/json"
        ],"parameters": [
          {
            "in": "header","name": "Authorization","description": "access token","required": true,"type": "String"
          },{
            "in": "body","name": "body","schema": {
              "$ref": "#/deFinitions/FrameRequest"
            }
          }
        ],"responses": {
          "200": {
            "description": "Success","schema": {
              "$ref": "#/deFinitions/FrameResponse"
            }
          }
        }
      }
    }
  }

可能是什么原因造成的?

解决方法

原来是我在用

services.AddSwaggerGen(c =>
        {
            c.OperationFilter<AuthorizationHeaderParameterOperationFilter>();

在我上过的课上

Schema = new OpenApiSchema() { Type = "String" },

应该以小写字母“ string”。