marshmallow-code / marshmallow-code/flask-marshmallow

AbsoluteURLFor: Field parameters are passed to URL

Open
#67 1 comment 3 reactions 0 assignees View on GitHub

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

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 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.