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.
See Modify
trait for details how add servers to OpenApi
.
Examples
Create new server with relative path.
Server::new("/api/v1");
Create server with custom url using a builder.
ServerBuilder::new().url("https://alternative.api.url.test/api").build();
Create server with builder and variable substitution.
ServerBuilder::new().url("/api/{version}/{username}")
.parameter("version", ServerVariableBuilder::new()
.enum_values(Some(["v1", "v2"]))
.default_value("v1"))
.parameter("username", ServerVariableBuilder::new()
.default_value("the_user")).build();
Structs
- Represents target server object. It can be used to alter server connection for path operations.
- Implements OpenAPI Server Variable used to substitute variables in
Server::url
. - Builder for
ServerVariable
with chainable configuration methods to create a newServerVariable
.