[Bug]: Schemas in query parameters don't work

Aperta
#1,022 7 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
42/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
openapi, python
Ambito
api

Direzione di ricerca

Start with the reproduced OpenAPI.from_file_path and unmarshal_request flow using RequestsOpenAPIRequest, then trace how query parameters with object schemas and patternProperties are handled. Confirm the existing reproduction with tag.foo and baz; done means the unmarshalled query results include the schema-matched tag.foo value while retaining baz.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

kind/bug
Actual Behavior

Query parameters with schemas are ignored when Unmarshalling

Expected Behavior

Query parameters matching a query parameter with a schema should be included in Unmarshall results.

Steps to Reproduce

Schema:

openapi: 3.1.0
info:
    title: Example
    version: "0.0"
servers:
  - url: 'http://example.com'
paths:
  /:
    get:
      parameters:
        - name: tag.{name}
          in: query
          schema:
              type: object
              patternProperties:
                  '^tag\.[A-Za-z0-9]+$':
                      type: string
                      pattern: '^[A-Za-z0-9]+$'
                  additionalProperties: false
        - name: baz
          in: query
          schema:
            type: string

Python script:

from openapi_core import OpenAPI
from openapi_core.contrib.requests import RequestsOpenAPIRequest
from requests import Request
import re

oas = OpenAPI.from_file_path('./exampleOas.yaml')
req = oas.unmarshal_request(RequestsOpenAPIRequest(Request(
    "GET",
    "http://example.com/",
    params={"tag.foo": "bar", "baz": "bat"})))

print(req)
# Returns
# RequestUnmarshalResult(errors=[], body=None, parameters=Parameters(query={'baz': 'bat'}, header={}, cookie={}, path={}), security={})

# Prove the regex works
print(re.search(r"^tag\.[A-Za-z0-9]+$", "tag.foo"))
# Returns
# <re.Match object; span=(0, 7), match='tag.foo'>
OpenAPI Core Version

0.19.5

OpenAPI Core Integration

requests

Affected Area(s)

unmarshalling

References

Such a pattern is described here and I've had confirmation on the OpenAPI slack here that this is the current best approach to describing pattern-based query parameter names.

This may be related to https://github.com/python-openapi/openapi-core/issues/250 but isn't completely related as it should work with the query default style of form.

Example of the use case I have for this.

Anything else we need to know?

No response

Would you like to implement a fix?

None

Lingua principale
Python
Stelle
368
Fork
140
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di python-openapi/openapi-core

Tutte le issue di python-openapi/openapi-core

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.