How to configure BASE_PATH in swagger open api?

11k views Asked by At

I am struggling to find a way to configure the BASE_PATH.

I want to configure the base path server side

I am using open-api-generator to generate subs from a swagger endpoint (asp core web api)

enter image description here

Is there a way to configure different BASE_PATH.

1

There are 1 answers

2
Jim Schubert On

How you define the base URL is specific to the version of OpenAPI Specification you target.

Swagger/OpenAPI 2.0

Define a host at the root of your document. For example:

swagger: "2.0"
info:
  version: 1.0.0
  title: Swagger Petstore
  license:
    name: MIT
host: petstore.swagger.io
basePath: /v1
schemes:
  - http
consumes:
  - application/json
produces:
  - application/json
paths:
  /pets:
    …

OpenAPI 3.x

Define a URL in servers at the root of your document. For example:

openapi: "3.0.0"
info:
  version: 1.0.0
  title: Swagger Petstore
  license:
    name: MIT
servers:
  - url: http://petstore.swagger.io/v1
paths:
  /pets:
    …