Skip to content

Add proc-macro for paths #9

Description

@LazyMechanic

Instead of describing the paths in the describe_api macro, I would like to have some proc-macro.

Instead of this:

describe_api! {
    // ...
    paths: {
        ("some" / "path" / { param: String }): {
            GET: {
                description: "Get smth",
                200: Smth,
                500: ApiError
            },
            POST: {
                description: "Do smth",
                200: None,
                500: ApiError
            },
        }
    }
}

describe api like this:

#[opg::path(
    path = "some/path/{param}",
    method = "GET",
    description = "Get smth",
    on_200 = "Smth",
    on_500 = "ApiError",
)]
async fn get_smth() -> Result<Smth, ApiError> {...}

#[opg::path(
    path = "some/path/{param}",
    method = "POST",
    description = "Get smth",
    on_200 = "None",
    on_500 = "ApiError",
)]
async fn do_smth() -> Result<(), ApiError> {...}

// ...

describe_api! {
    // ...
    paths: {
        get_smth,
        do_smth,
    }
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions