Skip to content

Commit

Permalink
fix(docs): properly attribute ABNF non-terminals from various RFCs (#155
Browse files Browse the repository at this point in the history
)

Refs #151
  • Loading branch information
char0n authored Dec 29, 2024
1 parent 9faf013 commit 8c5c800
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -241,21 +241,25 @@ The Path Templating is defined by the following [ABNF](https://tools.ietf.org/ht

```abnf
; OpenAPI Path Templating ABNF syntax
; variant of https://datatracker.ietf.org/doc/html/rfc3986#section-3.3
path-template = slash *( path-segment slash ) [ path-segment ]
path-segment = 1*( path-literal / template-expression )
slash = "/"
path-literal = 1*pchar
template-expression = "{" template-expression-param-name "}"
template-expression-param-name = 1*( %x00-7A / %x7C / %x7E-10FFFF ) ; every UTF8 character except { and } (from OpenAPI)
; Characters definitions (from RFC 3986)
; https://datatracker.ietf.org/doc/html/rfc3986#section-3.3
pchar = unreserved / pct-encoded / sub-delims / ":" / "@"
unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~"
; https://datatracker.ietf.org/doc/html/rfc3986#section-2.3
pct-encoded = "%" HEXDIG HEXDIG
; https://datatracker.ietf.org/doc/html/rfc3986#section-2.1
sub-delims = "!" / "$" / "&" / "'" / "(" / ")"
/ "*" / "+" / "," / ";" / "="
; https://datatracker.ietf.org/doc/html/rfc3986#section-2.2
; Characters definitions (from RFC 5234)
; https://datatracker.ietf.org/doc/html/rfc5234#appendix-B.1
ALPHA = %x41-5A / %x61-7A ; A-Z / a-z
DIGIT = %x30-39 ; 0-9
HEXDIG = DIGIT / "A" / "B" / "C" / "D" / "E" / "F"
Expand Down
8 changes: 6 additions & 2 deletions src/path-templating.bnf
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
; OpenAPI Path Templating ABNF syntax
; variant of https://datatracker.ietf.org/doc/html/rfc3986#section-3.3
path-template = slash *( path-segment slash ) [ path-segment ]
path-segment = 1*( path-literal / template-expression )
slash = "/"
path-literal = 1*pchar
template-expression = "{" template-expression-param-name "}"
template-expression-param-name = 1*( %x00-7A / %x7C / %x7E-10FFFF ) ; every UTF8 character except { and } (from OpenAPI)

; Characters definitions (from RFC 3986)
; https://datatracker.ietf.org/doc/html/rfc3986#section-3.3
pchar = unreserved / pct-encoded / sub-delims / ":" / "@"
unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~"
; https://datatracker.ietf.org/doc/html/rfc3986#section-2.3
pct-encoded = "%" HEXDIG HEXDIG
; https://datatracker.ietf.org/doc/html/rfc3986#section-2.1
sub-delims = "!" / "$" / "&" / "'" / "(" / ")"
/ "*" / "+" / "," / ";" / "="
; https://datatracker.ietf.org/doc/html/rfc3986#section-2.2

; Characters definitions (from RFC 5234)
; https://datatracker.ietf.org/doc/html/rfc5234#appendix-B.1
ALPHA = %x41-5A / %x61-7A ; A-Z / a-z
DIGIT = %x30-39 ; 0-9
HEXDIG = DIGIT / "A" / "B" / "C" / "D" / "E" / "F"
8 changes: 6 additions & 2 deletions src/path-templating.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,21 +153,25 @@ export default function grammar(){
this.toString = function toString(){
let str = "";
str += "; OpenAPI Path Templating ABNF syntax\n";
str += "; variant of https://datatracker.ietf.org/doc/html/rfc3986#section-3.3\n";
str += "path-template = slash *( path-segment slash ) [ path-segment ]\n";
str += "path-segment = 1*( path-literal / template-expression )\n";
str += "slash = \"/\"\n";
str += "path-literal = 1*pchar\n";
str += "template-expression = \"{\" template-expression-param-name \"}\"\n";
str += "template-expression-param-name = 1*( %x00-7A / %x7C / %x7E-10FFFF ) ; every UTF8 character except { and } (from OpenAPI)\n";
str += "\n";
str += "; Characters definitions (from RFC 3986)\n";
str += "; https://datatracker.ietf.org/doc/html/rfc3986#section-3.3\n";
str += "pchar = unreserved / pct-encoded / sub-delims / \":\" / \"@\"\n";
str += "unreserved = ALPHA / DIGIT / \"-\" / \".\" / \"_\" / \"~\"\n";
str += " ; https://datatracker.ietf.org/doc/html/rfc3986#section-2.3\n";
str += "pct-encoded = \"%\" HEXDIG HEXDIG\n";
str += " ; https://datatracker.ietf.org/doc/html/rfc3986#section-2.1\n";
str += "sub-delims = \"!\" / \"$\" / \"&\" / \"'\" / \"(\" / \")\"\n";
str += " / \"*\" / \"+\" / \",\" / \";\" / \"=\"\n";
str += " ; https://datatracker.ietf.org/doc/html/rfc3986#section-2.2\n";
str += "\n";
str += "; Characters definitions (from RFC 5234)\n";
str += "; https://datatracker.ietf.org/doc/html/rfc5234#appendix-B.1\n";
str += "ALPHA = %x41-5A / %x61-7A ; A-Z / a-z\n";
str += "DIGIT = %x30-39 ; 0-9\n";
str += "HEXDIG = DIGIT / \"A\" / \"B\" / \"C\" / \"D\" / \"E\" / \"F\"\n";
Expand Down

0 comments on commit 8c5c800

Please sign in to comment.