jmcarp / jmcarp/flask-apispec

Path Args Components Unable To Be Rendered

Open
#223 0 comments 7 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
652
Forks
151
PR merge metrics
No merged PRs in 30d

Description

With OpenAPI 3 and up the path arguments have to be inside a schema to be recognized. In paths.py argument_to_param the 'type', 'format', and 'default' are all just put in the param dictionary to fix this the spec version could be passed to argument_to_param and if it is >= 3 then put the previously mentioned values inside a schema dictionary inside of params. I'm sure there is a better fix but something like this would suffice:
```
def argument_to_param(argument, rule, spec_version, override=None):
param = {
'in': 'path',
'name': argument,
'required': True,
}
type_, format_ = CONVERTER_MAPPING.get(type(rule._converters[argument]), DEFAULT_TYPE)
if spec_version < 3:
param['type'] = type_
if format_ is not None:
param['format'] = format_
if rule.defaults and argument in rule.defaults:
param['default'] = rule.defaults[argument]
else:
param['schema'] = {}
param['schema']['type'] = type_
if format_ is not None:
param['schema']['format'] = format_
if rule.defaults and argument in rule.defaults:
param['schema']['default'] = rule.defaults[argument]
param.update(override or {})
return param
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in paths.py at argument_to_param and inspect its callers to understand how the OpenAPI specification version reaches path parameter generation. Compare the existing parameter shape for OpenAPI 2 and OpenAPI 3, then verify that type, format, and default are nested under schema for version 3 or later while older versions remain unchanged.

Written by the indexing model from the issue text.

Assessment

Tech stack
openapi, python
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.