Skip to content

Commit ec7fbb5

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 ec7fbb5

7 files changed

Lines changed: 1488 additions & 10 deletions

File tree

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,19 @@ 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+
# Install dependencies
20+
npm install
21+
22+
# Validate schema patterns
23+
npm run lint
24+
25+
# Run tests
26+
npm run test
27+
28+
# Type check
29+
npm run build
30+
```

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)