Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"host" is not generated if relative path is specified on the path or operation level in OAS file #691

Open
armen-ch opened this issue Mar 7, 2023 · 1 comment
Labels
question Further information is requested

Comments

@armen-ch
Copy link

armen-ch commented Mar 7, 2023

According to https://swagger.io/docs/specification/api-host-and-base-path/ "Relative URLs" if relative path is specified on the path level or operation level and if the definition hosted at http://localhost:3001/openapi.yaml and specifies url: /v2, the url is resolved to http://localhost:3001/v2.
So based on this my expectation is if I specify relative path on non-global level like below:

`openapi: 3.0.1
info:
  title: 'Test api'
  version: 1.0.0
servers:
  - url: http://localhost:3001
. . .
paths:
  '/products':
    get:
      servers:
        - url: /v2
. . .

then it should be resolved to http://localhost:3001/v2 and openapi-to-postman will generate something like:

         "request": {
            "name": "my request",
            "url": {
              "path": [
                "v2",
                "products"
              ],
              "host": [
                "{{baseUrl}}"
              ],
       . . .
       }

but currently the collection is generated without the host parameter:

         "request": {
            "name": "my request",
            "url": {
              "path": [
                "v2",
                "products"
              ],
       . . .
       }
@VShingala
Copy link
Member

@armen-ch So what's mentioned in the swagger docs is applicable to only where you use can use/link external resource via link directly. It doesn't not apply to servers as value of url in sever is absolute (i.e. string).

Also, URLs are relative to where file is hosted. So for example if it's hosted at localhost:1337/definition.yaml' than all resources you mention via relative URL should be present a localhost:1337/{resource}`.

To clarify more, see section "Overriding Servers". It states that The global servers array can be overridden on the path level or operation level.. It does not mention anything for relative URLs.

Examples mentioned in this doc have relative URLs for termsOfService and externalDocs where you can link URL itself where actual resource is present. There's no mention of server URLs also accepting relative URL here.

@VShingala VShingala added the question Further information is requested label May 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants