Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/331.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/google-sheets/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Swagger json验证未使用的模型警告_C#_Asp.net Core_Openapi_Swashbuckle.aspnetcore - Fatal编程技术网

C# Swagger json验证未使用的模型警告

C# Swagger json验证未使用的模型警告,c#,asp.net-core,openapi,swashbuckle.aspnetcore,C#,Asp.net Core,Openapi,Swashbuckle.aspnetcore,我对OpenApi json数据验证有问题。基于OpenApi验证(或editor.swagger.io),我的JSON文件中有未使用的模型。我应该去掉警告,几乎所有警告都来自System.Reflection命名空间 例如: : System.Reflection - Unused model: PropertyInfo - Unused model: MethodImplAttributes - Unused model: FieldAttributes - Unused model: Ev

我对OpenApi json数据验证有问题。基于OpenApi验证(或editor.swagger.io),我的JSON文件中有未使用的模型。我应该去掉警告,几乎所有警告都来自System.Reflection命名空间

例如:

: System.Reflection
- Unused model: PropertyInfo
- Unused model: MethodImplAttributes
- Unused model: FieldAttributes
- Unused model: EventAttributes
- Unused model: MethodAttributes
- Unused model: FieldInfo
- Unused model: PropertyAttributes 
:所有其他的

- Unused model: Type    --system
- Unused model: SecurityRuleSet --system.security
json是在我运行应用程序(.NET Core 3.1 with swagger包)时生成的

如果System.Reflection包在项目中的其他地方使用(或任何其他名称空间,如System.Security等),如何消除这些警告。我不能只是定制MS软件包来摆脱未使用的型号,这就是它的现状

是否有任何启动选项,我错过了在大摇大摆的设置,这是造成问题

警告(未使用的模型)没有给我任何堆栈跟踪、根或任何东西,仅仅因为项目中不存在未使用的模型

在项目中某处使用system.reflection的exmaple方法:

public async Task<IEnumerable<IssueSimple>> GetSimpleIssues(int id)
        {
            string method = MethodBase.GetCurrentMethod().Name; //that one using System.Reflection
            return null; // not to expose business logic
        }
json文件的一部分:

"PropertyInfo": {
       "type": "object",
       "properties": {
         "name": {
           "type": "string",
           "nullable": true,
           "readOnly": true
         },
         "declaringType": {
           "$ref": "#/components/schemas/Type"
         },
         "reflectedType": {
           "$ref": "#/components/schemas/Type"
         },
         "customAttributes": {
           "type": "array",
           "items": {
             "$ref": "#/components/schemas/CustomAttributeData"
           },
           "nullable": true,
           "readOnly": true
         },
         "isCollectible": {
           "type": "boolean",
           "readOnly": true
         },
         "metadataToken": {
           "type": "integer",
           "format": "int32",
           "readOnly": true
         },
         "memberType": {
           "$ref": "#/components/schemas/MemberTypes"
         },
         "propertyType": {
           "$ref": "#/components/schemas/Type"
         },
         "attributes": {
           "$ref": "#/components/schemas/PropertyAttributes"
         },
         "isSpecialName": {
           "type": "boolean",
           "readOnly": true
         },
         "canRead": {
           "type": "boolean",
           "readOnly": true
         },
        "canWrite": {
           "type": "boolean",
           "readOnly": true
         }
       },
       "additionalProperties": false

////////////////////////////////////////////////////
////////////////////////////////////////////////////
"PropertyAttributes": {
       "enum": [
         "None",
         "SpecialName",
         "RTSpecialName",
         "HasDefault",
         "Reserved2",
         "Reserved3",
         "Reserved4",
         "ReservedMask"
       ],
       "type": "string",
       "format": "int32"
     },


一般的问题是,当此模型未使用时,为什么要添加此选项?当MS软件包全局添加未使用的模型时,如何摆脱这些模型?

这是由内部控制器属性和错误返回类型(设置不正确)造成的。与openapi/swagger本身无关

public async Task<IEnumerable<IssueSimple>> GetSimpleIssues(int id)
        {
            string method = MethodBase.GetCurrentMethod().Name; //that one using System.Reflection
            return null; // not to expose business logic
        }
java -jar openapi-generator-cli-5.1.1.jar validate -i gittesting.json
"PropertyInfo": {
       "type": "object",
       "properties": {
         "name": {
           "type": "string",
           "nullable": true,
           "readOnly": true
         },
         "declaringType": {
           "$ref": "#/components/schemas/Type"
         },
         "reflectedType": {
           "$ref": "#/components/schemas/Type"
         },
         "customAttributes": {
           "type": "array",
           "items": {
             "$ref": "#/components/schemas/CustomAttributeData"
           },
           "nullable": true,
           "readOnly": true
         },
         "isCollectible": {
           "type": "boolean",
           "readOnly": true
         },
         "metadataToken": {
           "type": "integer",
           "format": "int32",
           "readOnly": true
         },
         "memberType": {
           "$ref": "#/components/schemas/MemberTypes"
         },
         "propertyType": {
           "$ref": "#/components/schemas/Type"
         },
         "attributes": {
           "$ref": "#/components/schemas/PropertyAttributes"
         },
         "isSpecialName": {
           "type": "boolean",
           "readOnly": true
         },
         "canRead": {
           "type": "boolean",
           "readOnly": true
         },
        "canWrite": {
           "type": "boolean",
           "readOnly": true
         }
       },
       "additionalProperties": false

////////////////////////////////////////////////////
////////////////////////////////////////////////////
"PropertyAttributes": {
       "enum": [
         "None",
         "SpecialName",
         "RTSpecialName",
         "HasDefault",
         "Reserved2",
         "Reserved3",
         "Reserved4",
         "ReservedMask"
       ],
       "type": "string",
       "format": "int32"
     },