Poem-openapi 1.0 released!

Poem-openapi is an OpenAPI server-side framework based on Poem. If you have used FastAPI, they are very similar in use.

The 1.0 version simplifies some macro attributes, making it more convenient to use.

How to use it

Poem-openapi book

Quick start

use poem::{listener::TcpListener, Route, Server};
use poem_openapi::{param::Query, payload::PlainText, OpenApi, OpenApiService};

struct Api;

impl Api {
  #[oai(path = "/hello", method = "get")]
  async fn index(
    #[oai(validator(max_length = 32))] name: Query<Option<String>>,
  ) -> PlainText<String> {
    match name.0 {
      Some(name) => PlainText(format!("hello, {}!", name)),
      None => PlainText("hello!".to_string()),

async fn main() -> Result<(), std::io::Error> {
  let api_service = OpenApiService::new(Api, "Hello World", "1.0")
  let ui = api_service.swagger_ui();

    .run(Route::new().nest("/api", api_service).nest("/", ui))

More examples



This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.