Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

vespera

БесплатноЗапускает вложенные скриптыНе проверен

Build APIs with Vespera - FastAPI-like DX for Rust/Axum. Covers route handlers, Schema derivation, and OpenAPI generation.

dev-five-gitот dev-five-git★ 30 звёзд на GitHub

Об этом скилле

Vespera Usage Guide

Vespera = FastAPI DX for Rust. Zero-config OpenAPI 3.1 generation via compile-time macro scanning.

API Naming Contract (MANDATORY)

API fields and query params are camelCase; ERD columns stay snake_case; drafts carry both (name + column). For example, the API field imageUrl maps to the ERD column image_url. Request, response and query structs must use #[serde(rename_all = "camelCase")]; use rename_all = "camelCase" with schema_type! as well. Keep multipart #[form_data(field_name = "imageUrl")] aligned with the same wire name. Different casing is a contract violation, not an equivalent spelling.

Quick Start

Dependencies: vespera (the only Vespera crate you depend on; axum is re-exported as vespera::axum), plus garde (for Validate), serde (derive) and tokio (#[tokio::main]).

use vespera::{vespera, Serve, Schema, Validated, axum::Json};
use vespera::axum::extract::Path;
use serde::{Deserialize, Serialize};
use garde::Validate;

// 1. Custom types — derive Schema for OpenAPI inclusion.
//    Add `garde::Validate` to opt into 422 validation.
#[derive(Serialize, Deserialize, Schema, Validate)]
pub struct CreateUser {
    #[garde(length(min = 3, max = 32))]
    pub name: String,
    #[garde(email)]
    pub email: String,
}

// 2. Route handlers — MUST be `pub async fn`.
#[vespera::route(get, path = "/{id}", tags = ["users"])]
pub async fn get_user(Path(id): Path<u32>) -> Json<CreateUser> {
    Json(CreateUser { name: format!("user{id}"), email: format!("user{id}@example.com") })
}

// 3. Validated extractor → automatic 422 on bad input.
#[vespera::route(post, tags = ["users"])]
pub async fn create_user(
    Validated(Json(req)): Validated<Json<CreateUser>>,
) -> Json<&'static str> {
    // `req` already passed validation. Failures never reach here.
    Json("ok")
}

// 4. Main — one-liner `.serve()` from the `Serve` extension trait.
#[tokio::main]
async fn main() -> std::io::Result<()> {
    vespera!(
        openapi  = "openapi.json", // writes file at compile time
        title    = "My API",
        version  = "1.0.0",
        license  = "MIT",          // info.license (SPDX); also description, summary,
                                   // terms_of_service, contact_{name,url,email},
                                   // license_name + license_url
        docs_url = "/docs",        // Swagger UI (pinned + SRI-checked assets)
        redoc_url = "/redoc",      // ReDoc alternative
        spec_url = "/openapi.json" // raw spec as application/json
    )
    .serve("0.0.0.0:3000")
    .await
}

Request Validation (Validated<T> → 422)

Wrap any extractor with Validated<...> to enforce garde::Validate before the handler runs. Vespera converts validation failures into a canonical 422 Unprocessable Entity response — no per-handler error mapping.

use vespera::{Validated, axum::Json};

#[vespera::route(post)]
pub async fn create(
    Validated(Json(req)): Validated<Json<CreateUser>>,
) -> Json<&'static str> {
    Json("ok")
}

Response on validation failure (status 422, content-type application/json):

{
  "errors": [
    { "path": "name",  "message": "length is lower than 3" },
    { "path": "email", "message": "not a valid email" }
  ]
}

Supported wrappers

Wrapper Validates
Validated<Json<T>> JSON body
Validated<Form<T>> URL-encoded form body
Validated<Query<T>> URL query string
Validated<Path<T>> Path parameters

Requirements

  • T (or the inner type of Json<T>, Form<T>, …) must implement garde::Validate<Context = ()>.
  • Derive garde::Validate and annotate fields with #[garde(...)] rules (length, email, range, pattern, custom, …).
  • Vespera's #[derive(Schema)] continues to drive the OpenAPI spec — the two derives compose cleanly on the same struct, and #[derive(Schema)] maps these #[garde(...)] rules to JSON Schema keywords: length(chars, ..) → minLength/maxLength (default byte-mode string length only maps min = 1), length on Vec/maps → minItems/ minProperties…, range → minimum/maximum, email/url/ipv4/ ipv6/ip → format (ip = anyOf; format is annotation-only under OpenAPI 3.1, so schema validators do not enforce it, but garde still does), pattern/prefix/suffix/ contains/ascii → pattern (+allOf), inner(..) → items. Explicit #[schema(...)] keywords win. Not documented: alphanumeric, required, custom, matches, credit_card, phone_number, dive, if, consts. Query<T> / Path<T> struct parameters carry the same constraints.
  • Or skip garde entirely: a runtime #[schema(...)] rule (min_length, format = "email", …) makes #[derive(Schema)] generate the impl. A rule-less struct or an enum has none, so Validated<Json<T>> with it fails at the argument with `` T cannot be validated by Validated / `Vali
Полный SKILL.md на GitHub

Установить vespera в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

.gitignoreAGENTS.mdCHANGELOG.mdCLAUDE.mdCargo.lockCargo.tomlLICENSEREADME.mdSECURITY.mdbun.lockbunfig.tomldeny.tomldevup.jsonoxlint.config.tspackage.jsontarpaulin.toml

FAQ

Что делает скилл vespera?

Build APIs with Vespera - FastAPI-like DX for Rust/Axum. Covers route handlers, Schema derivation, and OpenAPI generation.

Как установить скилл vespera?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл vespera запускает скрипты?

Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.

Похожие скиллы

Сравнить vespera с