{"record":{"id":"cf9c8ccfa9d65988","repo":"DioxusLabs/dioxus","slug":"use-api-route-instead-of-route-to-use-openapi","errorCode":null,"errorMessage":"Use `api_route` instead of `route` to use OpenAPI options","messagePattern":"Use `api_route` instead of `route` to use OpenAPI options","errorType":"validation","errorClass":"syn::Error","httpStatus":null,"severity":"error","filePath":"packages/fullstack-macro/src/lib.rs","lineNumber":637,"sourceCode":"                    path.push_str(&lit.value());\n                    path.push('}');\n                }\n                PathParam::Static(lit) => path.push_str(&lit.value()),\n            }\n        }\n\n        Some(path)\n    }\n\n    /// Removes the arguments in `route` from `args`, and merges them in the output.\n    pub fn from_route(\n        mut route: Route,\n        function: &ItemFn,\n        with_aide: bool,\n        method_from_macro: Option<Method>,\n    ) -> syn::Result<Self> {\n        if !with_aide && route.oapi_options.is_some() {\n            return Err(syn::Error::new(\n                Span::call_site(),\n                \"Use `api_route` instead of `route` to use OpenAPI options\",\n            ));\n        } else if with_aide && route.oapi_options.is_none() {\n            route.oapi_options = Some(OapiOptions {\n                summary: None,\n                description: None,\n                id: None,\n                hidden: None,\n                tags: None,\n                security: None,\n                responses: None,\n                transform: None,\n            });\n        }\n\n        let sig = &function.sig;\n        let mut arg_map = sig","sourceCodeStart":619,"sourceCodeEnd":655,"githubUrl":"https://github.com/DioxusLabs/dioxus/blob/393d190a801ccb441d41923e232289b4f8a5c669/packages/fullstack-macro/src/lib.rs#L619-L655","documentation":"Thrown by dioxus-fullstack's route macro expansion (CompiledRoute::from_route, packages/fullstack-macro/src/lib.rs:636). The function was annotated with the plain `#[route(...)]` attribute but its arguments include OpenAPI-only fields (summary, description, id, hidden, tags, security, responses, transform). Those fields are only accepted when the macro runs with aide/OpenAPI support enabled, i.e. via `#[api_route(...)]`. Using `route` with them is a compile error so the OpenAPI metadata is never silently dropped.","triggerScenarios":"Writing `#[route(GET, \"/pets\", summary = \"List pets\")]` (or any of the eight oapi fields inside a `#[route(...)]` attribute) instead of `#[api_route(...)]`. Also happens when copying an `api_route` example into a project where the aide/OpenAPI feature setup expects the `api_route` spelling, or when migrating code from `#[server]` endpoints documented with aide.","commonSituations":"Copying examples from Dioxus fullstack docs that use OpenAPI annotations while your code uses the plain `route` macro; enabling `dioxus/fullstack` with axum and adding OpenAPI metadata without switching the macro name; upgrading Dioxus versions where the split between `route` and `api_route` was introduced.","solutions":["Change the attribute from `#[route(...)]` to `#[api_route(...)]`, keeping the same arguments (e.g. `#[api_route(GET, \"/pets\", summary = \"List pets\")]`).","If you do not want OpenAPI docs, delete the OpenAPI fields (summary/description/id/hidden/tags/security/responses/transform) from the `#[route(...)]` attribute.","Make sure the `api_route` macro is imported/available (dioxus-fullstack with the axum/server features) so the renamed attribute resolves."],"exampleFix":"// before\n#[route(GET, \"/pets\", summary = \"List pets\")]\nasync fn list_pets() -> Json<Vec<Pet>> { ... }\n\n// after\n#[api_route(GET, \"/pets\", summary = \"List pets\")]\nasync fn list_pets() -> Json<Vec<Pet>> { ... }","handlingStrategy":"validation","validationCode":"# CI guard: fail if plain #[route(...)] uses OpenAPI-only keys\nrg -n '#\\[route\\([^)]*\\b(summary|description|id|hidden|tags|security|responses|transform)\\s*=' src/ && \\\n  { echo 'ERROR: use #[api_route] for OpenAPI options'; exit 1; } || true","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Adopt a repo convention: any endpoint with OpenAPI metadata uses #[api_route]; plain #[route] stays metadata-free.","Keep a trybuild UI test that pins the error message for route-with-oapi-options so regressions in examples fail CI."],"tags":["dioxus","proc-macro","openapi","routes","compile-time"],"backgroundTag":null,"analyzedSha":"393d190a801ccb441d41923e232289b4f8a5c669","analyzedAt":"2026-08-16T11:27:45.815Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}