Skip to content

Commit 4a81dcb

Browse files
committed
Add the style guide as a separate file
1 parent 31af874 commit 4a81dcb

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

style-guide.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
## Style Guide
2+
3+
Contributions to this repository should follow the style guide as described in this section.
4+
5+
### Markdown
6+
7+
Markdown files in this project should follow the style enforced by the [markdownlint tool](https://www.npmjs.com/package/markdownlint),
8+
as configured by the `.markdownlint.yaml` file in the root of the project.
9+
The `markdownlint` tool can also fix formatting, which can save time with tables in particular.
10+
11+
The following additional rules should be followed but currently are not enforced by tooling:
12+
13+
1. The first mention of a normative reference or an OAS-defined Object in a (sub)*section is a link, additional mentions are not.
14+
2. OAS-defined Objects such as Schema Objects are written in this style, and are not monospaced.
15+
3. Use "example" instead of "sample" - this spec is not about statistics.
16+
4. Use "OpenAPI Object" instead of "root".
17+
5. Fixed fields are monospaced.
18+
6. Field values are monospaced in JSON notation: `true`, `false`, `null`, `"header"` (with double-quotes around string values).
19+
7. A combination of fixed field name with example value uses JS notation: `in: "header"`, combining rules 5 and 6.
20+
8. An exception to 5-7 is colloquial use, for example "values of type `array` or `object`" - "type" is not monospaced, so the monospaced values aren't enclosed in double quotes.
21+
9. Use Oxford commas, avoid Shatner commas.
22+
10. Use `<span id="thing"></span>` for link anchors. The `<a name="thing"></a>` format has been deprecated.
23+
11. Headings use [title case](https://en.wikipedia.org/wiki/Title_case) and are followed by a blank line.
24+
25+
Plus some suggestions, rather than rules:
26+
27+
* Use one sentence per line in paragraphs and bullet points, to make diffs and edits easier to compare and understand.
28+
A blank line is needed to cause a paragraph break in Markdown.
29+
* In examples, use realistic values rather than foo/bar.
30+
31+
### Use of "keyword", "field", "property", and "attribute"
32+
33+
* JSON Schema keywords -> "keyword"
34+
* OpenAPI fixed fields -> "field"
35+
* property of a "plain" JSON object that is not an OpenAPI-defined Foo Object -> "property"
36+
* "attribute" is only used in the XML context and means "XML attribute"
37+
38+

0 commit comments

Comments
 (0)