Validator doesn't work with custom server url

未關閉
#95 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

評估

難度
3/5
預估耗時
1-2 天
新手友好度
45/100
Issue 類型
缺陷
描述清晰度
基本清楚
活躍度
停滯
技術堆疊
python, yaml
領域
api

研究方向

Start in handlers.py at the referenced line and reproduce the failure with the provided OpenAPI YAML, using the custom production server and /test endpoint. Trace how the validator resolves server URLs and verify that an appropriate default is used when the provided URL cannot be resolved; done means the endpoint validates without requiring a visible validation server entry.

由索引模型根據 Issue 內容生成。

描述

We are running a pyramid app with the following open api yaml definition :

openapi: 3.0.1
info:
  title: Sample API
  contact:
    name: API Support
    email: some.private@email.com
  version: 1.0.0
  x-audience: external-public
  description: |
    # Minimum 

servers:
  - url: https://client.public.api.com/
    description: Production Server
paths:
  /test:
    get:
      summary: "test path"
      operationId: my.app.function
      responses:
        200:
          description: will always return ok

Requests to the endpoint /test will fail with Server not found for http://0.0.0.0:8080/test unless the default server is added to the servers object:

servers:
  - url: https://some.private.api.com/
    description: Production Server
  - url: /
    description: Validation URL

it seems the url validator try to resolve the url in the servers field.

https://github.com/p1c2u/openapi-spec-validator/blob/master/openapi_spec_validator/handlers.py#L25

The validator should use the default server url as a fallback if the provided url can't be resolved.
I would like to avoid displaying the Validation URL to the api user.

note : first version incorrectly assumed a query was made on the url.

主要語言
Python
星號
409
分支
73
PR 合併指標
30 天內沒有已合併 PR

貢獻指南

開啟貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

python-openapi/openapi-spec-validator 的其他 Issue

查看 python-openapi/openapi-spec-validator 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。