Module salvo_oapi::server

source ·
Expand description

Implements OpenAPI Server Object types to configure target servers.

OpenAPI will implicitly add Server with url = "/" to OpenApi when no servers are defined.

Server can be used to alter connection url for path operations. It can be a relative path e.g /api/v1 or valid http url e.g. http://alternative.api.com/api/v1.

Relative path will append to the sever address so the connection url for path operations will become server address + relative path.

Optionally it also supports parameter substitution with {variable} syntax.

§Examples

Create new server with relative path.

Server::new("/api/v1");

Create server with custom url using a builder.

Server::new("https://alternative.api.url.test/api");

Create server with builder and variable substitution.

Server::new("/api/{version}/{username}")
    .add_variable("version", ServerVariable::new()
        .enum_values(["v1", "v2"])
        .default_value("v1"))
    .add_variable("username", ServerVariable::new()
        .default_value("the_user"));

Structs§