rethabile
rethabile

Reputation: 3199

do api documentation with swagger use live databases

I'm new to this api documentation era.

Vising this api documentation, I get to post and query data. I understand that's a demo api documentation with swagger.

But what happens with real world API documentation? do I have a documentation in demo.api.myawesome.com and actual api on api.myawesome. com using different data stores?

But again digging deeper, I got to find out that an api can be self documenting using swagger libraries. This seems like both api and documentation are using the same data store which can't be the case.

What am I missing here?

Upvotes: 2

Views: 1877

Answers (2)

Helen
Helen

Reputation: 97942

If you mean Swagger UI - the "try it out" button sends requests to the server specified by the host property in your spec. If host specifies your production server, requests will be sent to production; if it points to a sandbox, "try it out" will use the sandbox. You may have a version of the spec for internal use that points to production, and a public version that points to sandbox.

Note that Swagger supports authentication as a way to ensure that only authorized users (e.g. your actual customers with valid credentials or API keys) can make API calls.

You can omit host from the spec to disable the "try it out" functionality - this way you can still have the API docs, just without the interactive part.

Upvotes: 1

CDahn
CDahn

Reputation: 1876

From the Swagger website:

Swagger is a set of rules (in other words, a specification) for a format describing REST APIs. The format is both machine-readable and human-readable. As a result, it can be used to share documentation among product managers, testers and developers, but can also be used by various tools to automate API-related processes.

So yes, it uses the same "back end" as the actual API. It's just visualizing it, allowing you to interact with it via the Swagger UI.

Upvotes: 1

Related Questions