Skip to content

Commit 9ce9eae

Browse files
committed
fix(x-aep-resource): fix patterns regex
The patterns regex vas previously incorrect (not allowing for underscore ids).
1 parent 1d44c22 commit 9ce9eae

8 files changed

Lines changed: 1480 additions & 12 deletions

File tree

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ install:
1010
lint: install
1111
npx prettier --check **/*.md
1212

13-
# Format files with prettier
14-
format: install
13+
# Fix all files automatically, best effort.
14+
fix: install
1515
npx prettier --write **/*.md

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,13 @@ Common types used in AEPs
1212
aep.dev has registered the extension ids 1264-1274 with the [global extension registry](https://github.com/protocolbuffers/protobuf/blob/main/docs/options.md). Any extensions added to this project should use these values.
1313

1414
To minimize the need to add new ids to the global registry, additions should try to re-use the existing extensions as much as possible (for example, additional field annotations should be added as fields to `aep.api.field_info`).
15+
16+
### Quick Start
17+
18+
```bash
19+
# lint
20+
make lint
21+
22+
# fix as best as possible
23+
make fix
24+
```

json_schema/extensions/x-aep-resource.yaml

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,22 @@ properties:
2020
items:
2121
type: string
2222
# see https://aep.dev/4/#type-name
23-
pattern: "^[a-z0-9][.-a-z0-9/]*[a-z0-9]$"
24-
examples:
25-
- "library.example.com/author"
26-
- "library.example.com/user-profile"
23+
pattern: "^[a-z0-9][a-z0-9.-]*/[a-z0-9][-a-z0-9]*$"
24+
examples:
25+
- "library.example.com/author"
26+
- "library.example.com/user-profile"
2727
patterns:
2828
type: array
2929
description: The resource name patterns that are valid for this resource
3030
items:
3131
type: string
32-
pattern: "^[a-z][a-z0-9-]*/\\{[a-z][a-z0-9-]*\\}(/[a-z][a-z0-9-]*/\\{[a-z][a-z0-9-]*\\})*$"
32+
# see https://aep.dev/4/#annotating-resource-types
33+
# this asserts for a leading collection name and pairs of collection, id segments.
34+
pattern: "^[a-z][a-z0-9-]*(/\\{[a-z][a-z0-9_]*\\}|[a-z][a-z0-9-])*" # WIP
35+
examples:
36+
- "books/{book_id}"
37+
- "authors/{author_id}/books/{book_id}"
38+
- "authors/{author_id}/books/{book_id}"
3339
minItems: 1
3440
singleton:
3541
type: boolean
@@ -44,9 +50,8 @@ properties:
4450
description: >
4551
The type of resource, in the form of `{api name}.{resource singular}`.
4652
For example, `api.examples.com/user`.
47-
pattern:
48-
"^[a-z0-9][.-a-z0-9/]*[a-z0-9]$"
49-
# see https://aep.dev/4/#type-name
53+
# see https://aep.dev/4/#type-name
54+
pattern: "^[a-z0-9][a-z0-9_.]*/[a-z0-9][-a-z0-9]*$"
5055
examples:
5156
- "library.example.com/book"
5257
- "library.example.com/author"

0 commit comments

Comments
 (0)