我正在招摇我的api文件。我想为我的用户提供带有php和java选项的客户端sdk下拉列表。下面是我的代码。
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc();
services.AddSingleton(provider => Configuration);
services.AddTransient<IRegistrationRepository, ServiceUtilities>();
services.AddTransient<IClientServiceConnector, ClientServiceValidation>();
services.AddTransient<IEmailSender, EmailSender>();
services.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1", new Swashbuckle.AspNetCore.Swagger.Info
{
Title = "Onboarding API",
Version = "V1",
Description = "API to generate lead and return the url",
TermsOfService = "Please see terms and conditions",
Contact = new Swashbuckle.AspNetCore.Swagger.Contact {Name = "teggggrap",Email = "support@dd.com.au",Url= "https://www.dd.com.au/" }
});
var basePath = PlatformServices.Default.Application.ApplicationBasePath;
var xmlPath = Path.Combine(basePath, "gf.RegistrationApplication.xml");
c.IncludeXmlComments(xmlPath);
});
services.AddCors(options =>
{
options.AddPolicy("AllowAll", policy =>
{
policy.AllowAnyOrigin();
policy.AllowAnyHeader();
policy.AllowAnyMethod();
});
});
}
答案 0 :(得分:1)
您的API的消费者可以生成swagger-codegen,以便以您选择的语言为您的API创建客户端。您可能不想自己托管,但您可以向用户提供说明,转到https://editor.swagger.io/,他们可以上传您的API规范并从那里生成。
答案 1 :(得分:0)
我使用Codegen生成了我的php和JS SDK。它非常易于使用,然后您可以将文件夹推送到公共Github仓库,并从Swagger UI中,您可以告诉您的消费者访问并按照入门部分进行操作!
它为每个模型生成README.md和docs。