openapi.json
Accessing OpenAPI JSON Specification in undb
undb provides an API endpoint that allows developers to retrieve the OpenAPI JSON specification for a specific table within a base. This specification can be used to generate client libraries, create API documentation, or integrate with other tools that support OpenAPI.
How to Access the OpenAPI JSON Specification
To obtain the OpenAPI JSON specification for a specific table, you can send a GET
request to the following endpoint:
baseName
: The name of the base where the table resides.tableName
: The name of the table for which you want to retrieve the OpenAPI specification.
Example Request
Usage
Once you have retrieved the OpenAPI JSON file, you can use it in various ways:
-
Client Code Generation:
- You can generate client libraries in different programming languages using tools like
Swagger Codegen
orOpenAPI Generator
. This allows you to interact with your undb tables using a native client for your language of choice.
- You can generate client libraries in different programming languages using tools like
-
API Documentation:
- The OpenAPI JSON specification can be imported into API documentation tools like
Swagger UI
orRedoc
. This makes it easy to create user-friendly documentation for your API endpoints.
- The OpenAPI JSON specification can be imported into API documentation tools like
-
Integration with Other Tools:
- Many tools support OpenAPI specifications for purposes such as testing, monitoring, and automation. By integrating your undb API with these tools, you can streamline your development and deployment workflows.
Example: Using OpenAPI with Swagger UI
To visualize the API and interact with it via a browser, you can use Swagger UI
. Simply load the OpenAPI JSON file into Swagger UI to explore the API and make live requests.
- Install Swagger UI locally or use the hosted version.
- Provide the OpenAPI JSON URL or upload the file.
- Swagger UI will generate an interactive API documentation where you can test different endpoints and view the API structure.
Security
The API request to fetch the OpenAPI JSON specification requires a valid API token. This token should be passed in the x-undb-api-token
header. Make sure to keep your API tokens secure and rotate them regularly.
Example Response
Here’s a simplified version of the OpenAPI specification with a focus on key paths and components:
Benefits
- Automation: The OpenAPI spec automates client generation and API testing, reducing manual coding efforts.
- Consistency: Ensures consistency across your API consumers, as they all rely on the same API definitions.
- Ease of Integration: Simplifies integrating the undb API with third-party services or other internal systems.
By leveraging the OpenAPI specification provided by undb, developers can enhance productivity, improve API integration, and maintain high-quality documentation effortlessly.