maxspan
maxspan

Reputation: 14147

Showing DropDown for Client sdk in swaggerUI

I am having my api documetation in swagger. I would like to provide my users with Client sdk dropdown with options of php and java. below is my code.

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 = "[email protected]",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();
                });
            });
        }

Upvotes: 0

Views: 696

Answers (2)

lucyjosef
lucyjosef

Reputation: 762

I've generate my php and JS SDKs with Codegen. It's pretty easy to use and then you can push the folder to a public Github repo and from your Swagger UI, you can tell your consumers to visit and follow the Getting started section !

It generates README.md and docs for each model.

Here is my sdk

Upvotes: 0

Manny
Manny

Reputation: 11

The consumers of your API can generate swagger-codegen to create clients for your API in their language of choice. You probably don't want to host this yourself, but you could give your users instructions to go to https://editor.swagger.io/ where they can upload your API spec and generate it from there.

Upvotes: 1

Related Questions