Pylons / Pylons/pyramid_openapi3

support variables in the server config

Open
#178 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
84
Forks
46
Avg merge
5d 20h
Merged PRs (30d)
3

Description

servers:
  # - url: '/connect/api/v1' <-- required because below is not supported
  - url: '{connectUrl}/api/v1'
    variables:
      connectUrl:
        default: '/connect'
        description: The base URL of the server, including any subpaths to the connect site.
paths:
  /challenges/change-password:
    post:
      # <snip ...>

2022-10-25 14:55:22,889 ERROR [pyramid_openapi3][request=e4deab37-061d-4d3b-8119-ff3a09842061] 2.1 Server not found for http://localhost:5000/connect/api/v1/challenges/change-password

The following doesn't work unless I uncomment the extra server directive which kind of defeats the point of it being variable. Is there a way to turn off the validation entirely or do something to define the server directive more clearly? I think I'd like to be able to pass in a config-time value for the variable that I know when invoking config.pyramid_openapi3_spec(..., server_variables={'connectUrl': '/connect'})

This issue is directly related to https://github.com/Pylons/pyramid_openapi3/issues/104 and https://github.com/Pylons/pyramid_openapi3/issues/105 where I simply cannot get the openapi definition to work with an unknown subpath and could use some help. Everything in my document is defined relative to request.application_url but nothing doing the validation is aware of that.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the config.pyramid_openapi3_spec entry point and trace how server variables are handled during request validation. Read related issues 104 and 105, and compare validation against request.application_url. Done means an invocation-time server_variables value can support the documented variable URL without requiring a duplicate server directive.

Written by the indexing model from the issue text.

Assessment

Tech stack
openapi, python
Domain
api, backend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.