Skip to content

This is example code about "Auto-Generating & Validating OpenAPI Docs in Rust: A Streamlined Approach with Utoipa and Schemathesis".

Notifications You must be signed in to change notification settings

Identeco/utoipa-blog-example-code

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

85 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Identeco Utoipa & Schemathesis Example

The OpenAPI specification has become the industry standard for defining APIs. It is clear that ensuring accurate and up-to-date API documentation is essential for both users and developers. This example demonstrates how Utoipa and Schemathesis can be used in Rust projects to make the API documentation process less tedious and error-prone by automatically generating and validating an OpenAPI definition directly from code.

The code is based on real world usage of these tools at Identeco and their Credential Checker service. For a walkthrough behind the showcased concepts, read the full associated blog article "Auto-Generating & Validating OpenAPI Docs in Rust: A Streamlined Approach with Utoipa and Schemathesis" on Identeco's blog.

Prerequisites

Usage

To generate the OpenAPI docs, use:

cargo run --bin gen_api

and to start the server on localhost:8080, use:

cargo run --bin server

Once the server is running you can view the Swagger UI at localhost:8080/swagger-ui/.

Validation

To check if the openapi.yml file is up to date with the code, use:

cargo test

If you want to execute schemathesis locally, you can use the api-tests.sh script. Naturally, schemathesis and wait-for-it has to be installed on your system for that. An additional .gitlab-ci.yml file is included to demonstrate how to run the tests in a CI pipeline.

About

This is example code about "Auto-Generating & Validating OpenAPI Docs in Rust: A Streamlined Approach with Utoipa and Schemathesis".

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published