我对 CSharp 的生成 RestApiClient 有问题。在 Visual Studio AutoRest 中发现了问题,因此我下载了 AutoRest CLI,但生成了相同的错误方法返回类型。
AutoRest code generation utility [cli version: 3.0.6187; node: v12.14.1, max-memory: 8192 gb]
(C) 2018 Microsoft Corporation.
https://aka.ms/autorest
Showing All Installed Extensions
Type Extension Name Version
core @autorest/core 3.0.6274
core @microsoft.azure/autorest-core 2.0.4417
extension @microsoft.azure/autorest.csharp 2.3.84
extension @microsoft.azure/autorest.modeler 2.3.55
这是 Swashbucke 5.6.0 从 WebApi 生成的 Swagger.json
{
"swagger": "2.0",
"info": {
"version": "v1",
"title": "Server"
},
"host": "localhost:5992",
"schemes": [
"http"
],
"paths": {
"/api/User/HasUser": {
"post": {
"tags": [
"User"
],
"operationId": "User_HasUser",
"consumes": [],
"produces": [
"application/json",
"text/json",
"application/xml",
"text/xml"
],
"parameters": [
{
"name": "username",
"in": "query",
"required": true,
"type": "string"
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"x-nullable": false,
"type": "boolean"
}
}
}
}
}
},
"definitions": {}
}
带参数的命令
c:\> autorest --input-file=swagger.json --output-folder=autorest --csharp --clear-output-folder
AutoRest 的输出
namespace Api
{
using System;
using System.Collections;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Rest;
public static partial class UserExtensions
{
public static bool? HasUser(this IUser operations, string username) ...
}
}
我期待“布尔”而不是“布尔?”
public static bool HasUser(this IUser operations, string username) ...