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§
- Server
- Represents target server object. It can be used to alter server connection for path operations.
- Server
Builder - Builder for
Serverwith chainable configuration methods to create a newServer. - Server
Variable - Implements OpenAPI Server Variable used to substitute variables in
Server::url. - Server
Variable Builder - Builder for
ServerVariablewith chainable configuration methods to create a newServerVariable.