Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

v3.2: Allow Parameter/Header "examples" field with "content" field#4648

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
handrews wants to merge4 commits intoOAI:v3.2-devfromhandrews:content-examples

Conversation

handrews
Copy link
Member

@handrewshandrews commentedJun 2, 2025
edited
Loading

NOTE: This is a companion to PR#4647 that just adds to where we can use Example Objects as thesecond part of the three-part proposal. It is written assuming that PR would be merged because that makes the benefit more clear, although it could technically be done even without that PR. But that would be less useful since tools do not support the serialization rules for the old example fields.

Parameter and Header serialization is complex, particularly when using thecontent field to use a Media Type Object.

In such scenarios, the serialization occurs in two steps: The first step is to serialize the data to the media type, which can be captured by theexamples field of the Media Type Object.

The second is the encoding/escaping of the media type document for use in a URI, HTTP header, or other location with its own rules.

Sometimes the part needing illustration with an example is at one level, sometimes at another, and sometimes it is helpful to show both.

For simplicity, the "data" examples are always treated as the overall input data, so they would be the same at both levels. This is also because it is not always possible to show each step, particularly when there are binary serializations. This allows showing either step (or both steps) with both data and serialization, depending on what makes sense for the use case.

  • schema changes are included in this pull request
  • schema changes are needed for this pull request but not done yet
  • no schema changes are needed for this pull request

@handrewshandrews added param serializationIssues related to parameter and/or header serialization media and encodingIssues regarding media type support and how to encode data (outside of query/path params) example obj/keywordsIssues with the Example Object or exampel(s) keywords labelsJun 2, 2025
@handrewshandrews changed the titlev3.???: Allow Parameter/Header examples w/contentv3.???: Allow Parameter/Header "examples" field with "content" fieldJun 4, 2025
@handrewshandrews changed the titlev3.???: Allow Parameter/Header "examples" field with "content" fieldv3.2: Allow Parameter/Header "examples" field with "content" fieldJun 9, 2025
@handrewshandrews marked this pull request as ready for reviewJune 9, 2025 19:26
@handrewshandrews requested review froma team ascode ownersJune 9, 2025 19:26
handrewsand others added4 commitsJune 13, 2025 11:39
Parameter and Header serialization is complex, particularly whenusing the `content` field to use a Media Type Object.In such scenarios, the serialization occurs in two steps:The first step is to serialize the data to the media type, whichcan be captured by the `examples` field of the Media Type Object.The second is the encoding/escaping of the media type documentfor use in a URI, HTTP header, or other location with its own rules.Sometimes the part needing illustration with an example is at onelevel, sometimes at another, and sometimes it is helpful to showboth.For simplicity, the "data" examples are always treated as theoverall input data, so they would be the same at both levels.This is also because it is not always possible to show each step,particularly when there are binary serializations. This allowsshowing either step (or both steps) with both data and serialization,depending on what makes sense for the use case.
Co-authored-by: Karen Etheridge <github@froods.org>
@handrews
Copy link
MemberAuthor

Rebased with only minor conflicts (Git getting confused by adjacent changes, not multiple changes to the same line).

Comment on lines +1162 to +1178
examples:
spacesAndPluses:
description: Note handling of spaces and "+" per media type.
dataValue:
foo: a + b
bar: true
serializedValue:
foo=a+%2B+b&bar=true
examples:
spacesAndPluses:
description: |
Note that no additional percent encoding is done, as this
media type is URI query string-ready by definition.
dataValue:
foo: a + b
bar: true
serializedValue: foo=a+%2B+b&bar=true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Why twiceexamples with the same data and serialized values? Please add explanation what this is supposed to demonstrate, or reduce to one occurrence ofexamples.

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

@ralfhandl As noted on lines 1172-1174, the point of this is to show that you do notre-percent-encode the already-percent-encodedapplication/x-www-form-urlencoded media type. This is in contrast to other media types that wouldnot be percent-encoded in the Media Type Object'sexamples, butwould be percent-encoded in the Parameter Object'sexamples, which is shown in the next example.

I will figure out a better way to frame / show this.

ralfhandl reacted with heart emoji
Comment on lines +1196 to +1203
examples:
TwoNoFlag:
description:Serialize with minimized whitespace
dataValue:{
"numbers":[1, 2],
"flag":null
}
serializedValue:'{"numbers":[1,2],"flag":null}'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

What's the point of this innerexamples? As an example for the parameter it is useless and misleading as it shows a serialized value that is not valid for the paramter. It is technically allowed there, and valid for theschema without its context, and also "academic" and not a best practice we want people to adopt.

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

It is correct for the Media Type Object, which is the context of this Example Object. It shows an intermediate serialization step. It pairs with the previous example, but I will work out a better way to present this.

ralfhandl reacted with heart emoji
@handrews
Copy link
MemberAuthor

@ralfhandl I have not yet re-worked this, but there is also a way that this fits with PR#4728 that I just submitted. While the use case holds with or without that PR, its easier to see if you can re-use all of the Object types involved.

Basically, sometimes you might want to show examples at one level, and sometimes at an another. There are two levels here:

  • The Media Type Object, which does not show any special encoding or escaping, just what the media type requires
  • The Parameter or Header Object, which shows the special encoding/escaping/formatting required by the target location (some part of the URI or some or all of an HTTP header)

Showing two steps of serialization

This is where theapplication/jsonpath example comes in, although perhapsapplication/jsonl would be a better example as the data and serialized forms are different. I can see thatapplication/jsonpath is confusing because at the media type level there's no difference and why would you bother showing that? But I think somewhere in all of these PRs there is anapplication/jsonl example that would make more sense.

Regardless of where else you useapplication/jsonl, you might also want to shove it into a query string. For... reasons. (this is why I usedapplication/jsonpath- it actually makes sense in a query... but people use things in all sorts of weird places so.. idk what is the best example here). Anyway, at the Parameter Object level, you want to show the percent-encoding and any other parameter-specific serialization behavior.

With theapplication/jsonl now you have two non-trivial layers of serialization, and you actually might want to show both just to make it easier to understand. Jumping straight to something with half the characters percent-encoded requires a lot of mental gymnastics. Showing each step is advantageous.

The special case

There is also a special case:application/x-www-form-urlencoded includes, as part of its definition, URI percent-encoding. Part of what we need to show here is that if a media type does something like that,we do not apply the encoding twice. I was showing that by showing that the examples are identical at both levels.

As you note, you almost certainly would not do that in practice, although if you're assembling various re-usable components as#4728 allows, you might end up doing that more-or-less by accident.

It's probably worth adding a specific requirement along the lines of "Media types that already require URI percent-encoding MUST NOT be percent-encoded a second time when usingcontent to specify URI parameters" (and possibly similar language about headers, although encoding and headers is a whole different mess). Then we wouldn't need such a weird example.

@handrews
Copy link
MemberAuthor

The last force-push is a rebase to resolve conflicts plus one additional commit that removes theLink example because it is better addressed by PR#4740. The Set-Cookie guidance that is mentioned is PR#4748.

@handrews
Copy link
MemberAuthor

Between the ongoing debate overserializedValue in the Example Object and the discussions here, I'm re-thinking how to explain this better. Putting this in draft for now- I might revive it or close it in favor of new PRs.

@handrewshandrews marked this pull request as draftJuly 4, 2025 19:36
@handrews
Copy link
MemberAuthor

Closing in favor of PRs#4802 and#4801

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@karenetheridgekarenetheridgekarenetheridge left review comments

@ralfhandlralfhandlralfhandl left review comments

@baywetbaywetbaywet approved these changes

@Emilycroxall1996Emilycroxall1996Emilycroxall1996 approved these changes

Assignees
No one assigned
Labels
example obj/keywordsIssues with the Example Object or exampel(s) keywordsmedia and encodingIssues regarding media type support and how to encode data (outside of query/path params)param serializationIssues related to parameter and/or header serialization
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

5 participants
@handrews@karenetheridge@ralfhandl@baywet@Emilycroxall1996

[8]ページ先頭

©2009-2025 Movatter.jp