marshmallow-code / marshmallow-code/flask-marshmallow
AbsoluteURLFor: Field parameters are passed to URL
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 887
- Forks
- 65
- Avg merge
- 7h 25m
- Merged PRs (30d)
- 3
Description
I use `AbsoluteURLFor` for generating an URL to an image:
```python
from flask_marshmallow import Marshmallow
from flask_marshmallow.fields import AbsoluteURLFor
from marshmallow import fields
ma = Marshmallow()
class TestSchema(ma.Schema):
my_logo = AbsoluteURLFor(
'logo_api', # /api/logos/
id='',
dump_to='myLogo'
)
```
The resulting response is:
```json
{
"myLogo": "http://localhost:5000/api/logos/1?dump_to=myLogo"
}
```
The expected result is:
```json
{
"myLogo": "http://localhost:5000/api/logos/1"
}
```
If I skip the `dump_to`-parameter the result is:
```json
{
"my_logo": "http://localhost:5000/api/logos/1"
}
```
This is because the field parameter `dump_to` is passed as a parameter to `flask.url_for`. But this is (of course) not my intention. Can this be fixed or do I have to use another field like `Function` for example?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start from the AbsoluteURLFor field referenced in the issue and inspect how its field parameters are passed to flask.url_for. Reproduce the schema shown in the issue, then verify that dump_to still controls the serialized field name without appearing as a query parameter in the generated URL.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- flask, python
- Domain
- api
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100