DEV Community

Supraja Tangella
Supraja Tangella

Posted on

๐—จ๐—ป๐—น๐—ผ๐—ฐ๐—ธ ๐˜๐—ต๐—ฒ ๐—ฃ๐—ผ๐˜„๐—ฒ๐—ฟ ๐—ผ๐—ณ ๐—ข๐—ฝ๐—ฒ๐—ป๐—”๐—ฃ๐—œ ๐—ถ๐—ป ๐—”๐—ฆ๐—ฃ.๐—ก๐—˜๐—ง ๐—–๐—ผ๐—ฟ๐—ฒ: ๐—จ๐˜€๐—ถ๐—ป๐—ด ๐—ฆ๐˜„๐—ฎ๐—ด๐—ด๐—ฒ๐—ฟ ๐—จ๐—œ, ๐—ฆ๐—ฐ๐—ฎ๐—น๐—ฎ๐—ฟ, ๐—ฎ๐—ป๐—ฑ ๐—ฆ๐—ฝ๐—ฒ๐—ฐ๐˜๐—ฟ๐—ฎ๐—น ๐—ณ๐—ผ๐—ฟ ๐—•๐—ฒ๐˜๐˜๐—ฒ๐—ฟ ๐—”๐—ฃ๐—œ ๐——๐—ผ๐—ฐ๐˜‚๐—บ๐—ฒ๐—ป๐˜๐—ฎ๐˜๐—ถ๐—ผ๐—ป ๐—ฎ๐—ป๐—ฑ ๐—ง๐—ฒ๐˜€๐˜๐—ถ๐—ป๐—ด

๐Ÿญ. ๐—ฆ๐˜„๐—ฎ๐—ด๐—ด๐—ฒ๐—ฟ ๐—จ๐—œ โ€“ ๐—Ÿ๐—ผ๐—ฐ๐—ฎ๐—น ๐—”๐—ฑ-๐—›๐—ผ๐—ฐ ๐—”๐—ฃ๐—œ ๐—ง๐—ฒ๐˜€๐˜๐—ถ๐—ป๐—ด

Swagger UI provides an interactive web interface to visualize and test your OpenAPI documents locally. It is widely used to explore and verify API endpoints during development.

๐—ฃ๐˜‚๐—ฟ๐—ฝ๐—ผ๐˜€๐—ฒ: Quickly test your API endpoints with an intuitive UI directly in your ASP.NET Core app.

๐—–๐—ผ๐—ฑ๐—ฒ ๐˜€๐—ป๐—ถ๐—ฝ๐—ฝ๐—ฒ๐˜:

builder.Services.AddOpenApi();

app.MapOpenApi();

app.UseSwaggerUI(options =>
{
options.SwaggerEndpoint("/openapi/v1.json", "v1");
});

Access it at: https://localhost:<port>/swagger

Enable "launchBrowser": true and set "launchUrl": "swagger" in launchSettings.json to auto-open the app at the Swagger UI URL using the HTTPS profile.

๐Ÿฎ. ๐—ฆ๐—ฐ๐—ฎ๐—น๐—ฎ๐—ฟ โ€“ ๐—œ๐—ป๐˜๐—ฒ๐—ฟ๐—ฎ๐—ฐ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—”๐—ฃ๐—œ ๐——๐—ผ๐—ฐ๐˜‚๐—บ๐—ฒ๐—ป๐˜๐—ฎ๐˜๐—ถ๐—ผ๐—ป

Scalar is an open-source UI alternative for OpenAPI documentation, designed to provide an interactive experience similar to Swagger UI.

๐—ฃ๐˜‚๐—ฟ๐—ฝ๐—ผ๐˜€๐—ฒ: Offer a clean and customizable interactive API doc experience integrated with your OpenAPI endpoint.

๐—–๐—ผ๐—ฑ๐—ฒ ๐˜€๐—ป๐—ถ๐—ฝ๐—ฝ๐—ฒ๐˜:

builder.Services.AddOpenApi();
app.MapOpenApi();
app.MapScalarApiReference();

Access it at: https://localhost:<port>/scalar/v1

Set "launchBrowser": true and "launchUrl": "scalar/v1" in launchSettings.json to auto-launch the app at the Scalar UI URL with the HTTPS profile.

๐Ÿฏ. ๐—ฆ๐—ฝ๐—ฒ๐—ฐ๐˜๐—ฟ๐—ฎ๐—น โ€“ ๐—Ÿ๐—ถ๐—ป๐˜๐—ถ๐—ป๐—ด ๐—ข๐—ฝ๐—ฒ๐—ป๐—”๐—ฃ๐—œ ๐——๐—ผ๐—ฐ๐˜‚๐—บ๐—ฒ๐—ป๐˜๐˜€

Spectral is a powerful linter that checks your OpenAPI document for errors and best practice violations during build time, helping ensure high-quality API definitions.

๐—ฃ๐˜‚๐—ฟ๐—ฝ๐—ผ๐˜€๐—ฒ: Automatically validate and maintain consistency in your OpenAPI documents.

๐—ฆ๐—ฒ๐˜๐˜‚๐—ฝ ๐˜€๐—ป๐—ถ๐—ฝ๐—ฝ๐—ฒ๐˜ (๐—ถ๐—ป .๐—ฐ๐˜€๐—ฝ๐—ฟ๐—ผ๐—ท):

true

$(MSBuildProjectDirectory)

Run lint:

spectral lint WebMinOpenApi.json

๐—ช๐—ต๐—ถ๐—ฐ๐—ต ๐˜๐—ผ๐—ผ๐—น ๐—ฑ๐—ผ ๐˜†๐—ผ๐˜‚ ๐—ฟ๐—ฒ๐—น๐˜† ๐—ผ๐—ป ๐—บ๐—ผ๐˜€๐˜ ๐—ณ๐—ผ๐—ฟ ๐—”๐—ฃ๐—œ ๐—ฑ๐—ผ๐—ฐ๐˜‚๐—บ๐—ฒ๐—ป๐˜๐—ฎ๐˜๐—ถ๐—ผ๐—ป ๐—ฎ๐—ป๐—ฑ ๐˜๐—ฒ๐˜€๐˜๐—ถ๐—ป๐—ด ๐—ถ๐—ป ๐˜†๐—ผ๐˜‚๐—ฟ ๐—ฝ๐—ฟ๐—ผ๐—ท๐—ฒ๐—ฐ๐˜๐˜€? ๐—›๐—ฎ๐˜ƒ๐—ฒ ๐˜†๐—ผ๐˜‚ ๐˜๐—ฟ๐—ถ๐—ฒ๐—ฑ ๐—ฐ๐—ผ๐—บ๐—ฏ๐—ถ๐—ป๐—ถ๐—ป๐—ด ๐˜๐—ต๐—ฒ๐˜€๐—ฒ ๐˜๐—ผ๐—ผ๐—น๐˜€ ๐—ณ๐—ผ๐—ฟ ๐—ฎ ๐—บ๐—ผ๐—ฟ๐—ฒ ๐—ฟ๐—ผ๐—ฏ๐˜‚๐˜€๐˜ ๐—ข๐—ฝ๐—ฒ๐—ป๐—”๐—ฃ๐—œ ๐˜„๐—ผ๐—ฟ๐—ธ๐—ณ๐—น๐—ผ๐˜„?

Top comments (0)