Skip to content

Extend preferredScheme to become baseUrl #102

Closed
@ErikWittern

Description

@ErikWittern

A recent issue (#96) lead to a pull request (#97) by @thejibz introducing the option to pass a preferredScheme, e.g., to specify whether to use http or https.

This option is relevant mostly in the context of Swagger definitions, though, and does not apply well to OAS 3 definitions: while the former define the base URL to call using schemes, host, and basePath fields, the latter use one of multiple Server Objects to do so. Thus, in the case of an OAS 3 definition being passed to OASGraph, some questions arise: what is the expected behavior if, let's say, preferredScheme is set to https but there are multiple server objects that define a URL with https? What if none of the server objects defines a URL with https? What if different operations in the OAS reference different server objects with different schemes?

Thinking about this, one compromise may be to extend the preferredScheme option by changing it into a baseUrl option. By providing a base URL to call, this option would encompass the functionality provided by preferredScheme in the context of a Swagger being passed to OASGraph. In addition, there could be simple semantics to also solve the issue of selecting a server object to use when an OAS 3 is passed to OASGraph: if present, OASGraph will always use the passed baseUrl for requests, and ignore server objects. This simplified behavior has, of course, the downside of not allowing to use different servers for different operations. However, if that is desired, I would argue that the OAS definition needs to be changed accordingly. A baseUrl option would still be valuable for development and testing purposes.

@thejibz and @Alan-Cha, what do you think?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions