Skip to content

Feat/support examples property#999

Merged
lafrech merged 6 commits intomarshmallow-code:devfrom
SeitaBV:feat/support-examples-property
Nov 30, 2025
Merged

Feat/support examples property#999
lafrech merged 6 commits intomarshmallow-code:devfrom
SeitaBV:feat/support-examples-property

Conversation

@Flix6x
Copy link
Copy Markdown
Contributor

@Flix6x Flix6x commented Nov 18, 2025

I realize you did some work yourself on supporting the examples property, but I'm not sure if that is still ongoing. The examples branch hasn't been updated in 3 years.

Related discussion on supporting OpenAPI 3.1: #579

The OpenAPI upgrading docs suggest moving from example to examples, but as of now, both seem to be supported, so I haven't removed the singular example from the list of valid properties.

Signed-off-by: F.N. Claessen <felix@seita.nl>
Signed-off-by: F.N. Claessen <felix@seita.nl>
Signed-off-by: F.N. Claessen <felix@seita.nl>
Signed-off-by: F.N. Claessen <felix@seita.nl>
Signed-off-by: F.N. Claessen <felix@seita.nl>
@lafrech
Copy link
Copy Markdown
Member

lafrech commented Nov 20, 2025

Hi. Thanks for contributing.
In flask-smorest, I use examples extensively (see for instance marshmallow-code/flask-smorest#68) without the need for this change here. But there I do it at schema level while this change acts at field level, which I guess is fine, too, so I guess you're (I was) right about it.
Perhaps the unit tests would clarify the use case. Do you think you could add one?

Signed-off-by: F.N. Claessen <felix@seita.nl>
@Flix6x
Copy link
Copy Markdown
Contributor Author

Flix6x commented Nov 22, 2025

Thanks, indeed my use case is field examples rather than schema examples. Something like this? I noticed two things:

  1. The test would fail on dev, as expected.
  2. The test succeeds on feat/support-examples-property, which I feel is somewhat unexpected, given that the fixture checks version 2.0 and 3.0.0. At first I thought the field examples were introduced in v3.1, but I think 3.0 already had them. 2.0 not, though.

@lafrech
Copy link
Copy Markdown
Member

lafrech commented Nov 30, 2025

Thanks!

The test succeeds on feat/support-examples-property, which I feel is somewhat unexpected, given that the fixture checks version 2.0 and 3.0.0. At first I thought the field examples were introduced in v3.1, but I think 3.0 already had them. 2.0 not, though.

apispec doesn't check that the user uses properties that are valid wrt OpenAPI version.

@lafrech lafrech merged commit e25f2d4 into marshmallow-code:dev Nov 30, 2025
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants