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.
Server::builder().url("https://alternative.api.url.test/api").build();
Create server with builder and variable substitution.
Server::builder().url("/api/{version}/{username}")
.parameter("version", ServerVariable::builder()
.enum_values(["v1".into(), "v2".into()])
.default_value("v1"))
.parameter("username", ServerVariable::builder()
.default_value("the_user")).build();
Structs§
- Server
- Represents target server object. It can be used to alter server connection for path operations.
- Server
Builder - Use builder syntax to set the inputs and finish with
build()
. - Server
Variable - Implements OpenAPI Server Variable used to substitute variables in
Server::url
. - Server
Variable Builder - Use builder syntax to set the inputs and finish with
build()
.