docs(larql-server): Added Swagger UI for API Documentation#47
Open
priyanshu891 wants to merge 1 commit intochrishayuk:mainfrom
Open
docs(larql-server): Added Swagger UI for API Documentation#47priyanshu891 wants to merge 1 commit intochrishayuk:mainfrom
priyanshu891 wants to merge 1 commit intochrishayuk:mainfrom
Conversation
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
Adds interactive API documentation to
larql-servervia an auto-generated OpenAPI 3 spec and an embedded Swagger UI. Every HTTP handler on the server is now annotated with#[utoipa::path(...)], request/response bodies have typedToSchemamirrors, and the spec is served live from the running process — no build step, no hand-maintained YAML.What's new
GET /swagger-ui— browse-friendly, try-it-out Swagger UI.GET /v1/openapi.json— the raw OpenAPI 3 spec (useful for codegen, Postman, Insomnia, etc.).--no-docsCLI flag to disable both endpoints for hardened deployments.Docs are mounted before the auth middleware (consistent with
--cors) so they stay reachable without an API key. Flip the ordering in bootstrap.rs if you want docs gated behind the key.Coverage
All public HTTP surfaces are documented and grouped under the following tags:
browse/v1/describe,/v1/walk,/v1/relations,/v1/stats,/v1/topology,/v1/modelsinference/v1/select,/v1/infer,/v1/explain,/v1/insert,/v1/warmuppatches/v1/patches(apply / list / remove)expert/v1/walk-ffn,/v1/walk-ffn-q8k,/v1/expert,/v1/expert/batch,/v1/experts/layer-batch(-f16),/v1/experts/multi-layer-batch(-q8k)openai/v1/embeddings,/v1/completions,/v1/chat/completionsadmin/v1/health,/v1/embed,/v1/logits,/v1/token/{encode,decode},/v1/streamMulti-model variants (
/v1/{model_id}/...) are documented alongside their single-model counterparts.Implementation notes
#[derive(OpenApi)]ApiDoc, aschemassubmodule withSerialize + ToSchemaresponse mirrors for handlers returningJson<serde_json::Value>, shared path params (e.g.ModelIdParam), and aswagger_router()helper that merges into the main app router.ServerErrornow serialises through a typedErrorBody { error: String }(see error.rs) so error responses appear in the spec instead of being untyped JSON.utoipa = "5"(withaxum_extras+preserve_order) andutoipa-swagger-ui = "9"(withaxum).#[allow(dead_code)]/ never constructed at runtime — they exist solely to drive spec generation.Test plan
cargo build -p larql-serversucceeds.cargo test -p larql-serverpasses.GET /swagger-uirenders the interactive UI.GET /v1/openapi.jsonreturns a valid OpenAPI 3 document (e.g. paste into https://editor.swagger.io).browse,inference,expert,openai,patches,admin) is populated./v1/healthand/v1/describe?entity=Franceworks.--no-docsand confirm both endpoints return 404.--api-key <key>and confirm/swagger-ui+/v1/openapi.jsonremain reachable without the key (by design — same as--cors)./v1/{model_id}/describeetc. appear in the spec.