Skip to content

Questions about Server Variable binding and defaults #1675

Closed
@tedepstein

Description

@tedepstein

I'm reading about Server Objects and Server Variables, and trying to understand how resolution/expansion is supposed to work.

The OpenAPI document can specify any number of servers, each with zero or more variables. Each variable can be an arbitrary string, or can be constrained to a string enum. Also, each variable MUST specify a default value.

Here are my questions:

  • I guess one of the envisioned scenarios involves a service implementation that binds the server variables at runtime, according to the host, port, and path where the server is running. So it creates a new OpenAPI document with the variables resolved, and passes this to the client. Is that right?

  • Another possible scenario is where the API consumer retrieves the original OpenAPI spec, with unbound variables, and dynamically resolves them with some known values. The client may have those server variable values supplied in a configuration file, or they may be provided by a human user at runtime. Correct?

  • I don't see anything in the OpenAPI spec that tells us how variable resolution is expected to happen, or how it should be coordinated between the client and the OpenAPI document provider (which may or may not be the same as the server). I suppose the IANA-registered media type for OpenAPI documents, when we have one, could include a protocol for server variable binding in headers or query parameters, but I don't see any mention of this in the referenced issue. So, is it fair to say that server variable binding is entirely implementation-dependent?

  • The default property of a Server Variable Object has this description in the spec:

    REQUIRED. The default value to use for substitution, and to send, if an alternate value is not supplied. Unlike the Schema Object's default, this value MUST be provided by the consumer.

    I don't understand what "by the consumer" means in this context, or maybe I'm just finding it confusing.

    • Is this just trying to say that each Server Variable MUST specify a default value? In that case it would not be the "consumer" who provides the default; it would be the OpenAPI document author or provider, right?
    • Or is it trying to say that if a value other than the default needs to be bound to the variable, then the "consumer" must provide that value? In that case it seems odd to say that consumer MUST do this, when there is no explicit mechanism specified for doing so. Maybe it would be a little more natural to say that it is up to the implementation, on the client side or the provider side, to substitute non-default values.

Any clarifications or comments appreciated.

Metadata

Metadata

Assignees

Labels

clarificationrequests to clarify, but not change, part of the specreview

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions