Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Define style for field names and values in YAML comments / $comment strings #4305

Open
handrews opened this issue Jan 16, 2025 · 1 comment
Labels
editorial Wording and stylistic issues
Milestone

Comments

@handrews
Copy link
Member

We currently use Markdown formatting in some comments, which doesn't do anything and can (particularly with backtics) read strangely to those not familiar with our variant of Markdown. See PR #4301 for some examples highlighted by @ralfhandl , but I have asked to separate the concern out of that PR since it is a problem in more places than just that.

Sometimes we do want Markdown in field values (because the OAS supports it), but example comments are not one of those places. On the other hand, if we just use the same formatting in example comments for field names that we use for things that aren't field names elsewhere in the spec, that seems a bit confusing, too.

@handrews handrews added the editorial Wording and stylistic issues label Jan 16, 2025
@handrews handrews added this to the v3.1.2 milestone Jan 16, 2025
@ralfhandl
Copy link
Contributor

ralfhandl commented Jan 18, 2025

Styles currently used:

# [...] default is `v2`

# The default with "contentEncoding" is application/octet-stream,

# default for primitives without a special format is text/plain

# default for string with binary format is `application/octet-stream`

# default for arrays is based on the type in the `items`
# subschema, which is an object, so `application/json`

# default is `text/plain`

# default based on the `items` subschema would be
# `application/json`, but we want these address objects
# serialized as `application/xml` instead

# default is application/octet-stream, but we can declare
# a more specific image type or types

# The property name 'file' will be used for all files.

# get the `id` field from the request path parameter named `id`

# get the `uuid` field from the `uuid` field in the response body

# returns array of '#/components/schemas/repository'

Cat: # "Cat" will be used as the discriminating value

Dog: # "Dog" will be used as the discriminating value

# all other properties specific to a `Cat`

# all other properties specific to a `Dog`

# all other properties specific to a `Lizard`

I find double-quotes for field names and field values most readable in the rendered YAML examples:

# Use "foo": "bar" consistently

If we want to use one style for YAML comments and $comment field values in JSON files, single-quotes may be easier to write because they don't need escaping:

"$comment": "Use 'foo': 'bar' consistently"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
editorial Wording and stylistic issues
Projects
None yet
Development

No branches or pull requests

2 participants