marshmallow-code / marshmallow-code/apispec

Generating labels of validate.OneOf(labels=[..]) in the json schema

Open
#679 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
1.2k
Forks
202
Avg merge
3h 38m
Merged PRs (30d)
3

Description

Hi,

I have the following field in marshmallow:

```python
the_field = fields.Integer(validate=[validate.OneOf([1, 2, 3], labels=['one', 'two', 'three'])])
```

And the resulting json:
```
"the_field": {
"type": "integer",
"enum": [
1,
2,
3
]
}
```

Is there a way to also print the labels `['one', 'two', 'three']` in the json ?

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

No file or test is named in the issue. Start by locating the schema-generation path that handles marshmallow validate.OneOf and compare its current enum output with the requested labels; done means the generated JSON schema represents the labels as intended and existing behavior remains covered.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.