Skip to content

Structural improvements: enhance schemes, host and basePath handling #686

Closed
@arno-di-loreto

Description

@arno-di-loreto

On OpenAPI spec current version, schemes, host and basePath are handled this way

  • schemes, host and basePath are declared on root level
  • schemes can be overidden on operation
schemes:
  - http
  - https
host: api.domain.com
basePath: /basepath
paths:
  /resources:
    get:
      schemes:
        - https

With current version:

  • you can only declare one environment in a OpenAPI spec file
  • all paths and operations shares the same host and basePath
  • you can only override schemes

Proposed enhancement

1 - Create a new urls object:

urls:
    # (new) Grouping schemes, host and basePath and add optional environments handling.
    schemes:
      # (existing) Moved from root to urls.
      # These schemes are used by all environments if multiple environments are defined.
    host:
      # (existing) Moved from root to urls.
      # This host is used by all environments if multiple environments are defined.
    basePath:
      # (existing) Moved from root to urls.
      # Base path used all environments if multiple environments are defined.
    externalDocs:
      # (new) link to some external documentation
    defaultEnvironment:
      # (new) default environment name if multiple environments are defined
    {environment name}:
      # (new) optional definition per environment
      schemes:
        # (new) schemes for this environment.
        #  Overrides urls.schemes
      host:
        # (new) host for this environnement
        # Overrides urls.host
      basePath:
        # (new) base path for this environment
        # Overrides urls.basePath
      externalDoc:
        # (new) link to some external documentation for this environment

2 - use this new object in paths and its sub-levels (cf. OAI/sig-moonwalk#115 )

# schemes, host and basePath are removed from root
paths:
  # url object can be defined on any level in paths object (paths, path, operation)
  urls:
    # will apply on all paths and operation
    schemes:
      - http
      - https
    basePath: /basepath
    sandbox:
       # host for sandbox environment
       host: api.sandbox.domain.com
    production:
       # host for production environment
       host: api.domain.com
  /resources:
    urls:
      # will apply on all operations
      # declared properties override paths urls properties
      schemes:
        # overriding paths schemes
        - http
    post:
      urls:
        # will apply on this operation
        # declared properties override /resources urls properties
        schemes:
          # overriding /resources schemes
          - https 
        sandbox:
          # overriding host for sandbox environment 
          host: api.sandbox.specific.domain.com
        production:
          # overriding host for production environment
          host: api.specific.domain.com 

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