Skip to content

Commit ad4c79d

Browse files
committed
chore: prepare release 0.1.0
1 parent 4bbec1b commit ad4c79d

File tree

2 files changed

+41
-3
lines changed

2 files changed

+41
-3
lines changed

CHANGELOG.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/)
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8-
## 0.1.0-alpha.1 - 2023-05-01
8+
## 0.1.0 - 2023-05-07
99

1010
### Added
1111

12-
- Set up initial repository structure and files.
12+
- Support parsing Lexicon schemas as of commit-ish [aabbf43](https://github.com/bluesky-social/atproto/blob/aabbf43a7f86b37cefbba614d408534b59f59525/packages/lexicon/src/types.ts) of [@atproto/lexicon](https://www.npmjs.com/package/@atproto/lexicon).
13+
- There is a known issue when attempting to resolve references that use fragment identifiers that assume a reference to a value within the same document (i.e., they use `#something` instead of `com.example.method#something`). This library cannot yet resolve these references.
1314

1415
### Changed
1516

README.md

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@
1616

1717
## About
1818

19+
socialweb/atproto-lexicon parses [Lexicon schemas][] for the [AT Protocol][].
20+
21+
The current version is compliant with [@atproto/lexicon][] at commit-ish
22+
[aabbf43][].
23+
1924
This project adheres to a [code of conduct](CODE_OF_CONDUCT.md).
2025
By participating in this project and its community, you are expected to
2126
uphold this code.
@@ -30,7 +35,7 @@ composer require socialweb/atproto-lexicon
3035

3136
## Usage
3237

33-
``` php
38+
```php
3439
use SocialWeb\Atproto\Lexicon\Nsid\Nsid;
3540
use SocialWeb\Atproto\Lexicon\Parser\DefaultParserFactory;
3641
use SocialWeb\Atproto\Lexicon\Parser\DefaultSchemaRepository;
@@ -48,6 +53,32 @@ $schemaContents = file_get_contents((string) $schemaFile);
4853
$document = $parser->parse((string) $schemaContents);
4954
```
5055

56+
### Resolving References
57+
58+
Using this library, you may resolve references in Lexicon schemas.
59+
60+
For example:
61+
62+
```php
63+
foreach ($document->defs as $defId => $def) {
64+
if ($def instanceof LexRef) {
65+
$resolved = $def->resolve();
66+
}
67+
68+
if ($def instanceof LexRefUnion) {
69+
foreach ($def->getLexRefs() as $ref) {
70+
$resolved = $ref->resolve();
71+
}
72+
}
73+
74+
if ($def instanceof LexString) {
75+
foreach ($def->getLexRefsForKnownValues() as $ref) {
76+
$resolved = $ref->resolve();
77+
}
78+
}
79+
}
80+
```
81+
5182
## Contributing
5283

5384
Contributions are welcome! To contribute, please familiarize yourself with
@@ -67,3 +98,9 @@ under the terms of the GNU Lesser General Public License (LGPL-3.0-or-later)
6798
as published by the Free Software Foundation. Please see
6899
[COPYING.LESSER](COPYING.LESSER), [COPYING](COPYING), and [NOTICE](NOTICE)
69100
for more information.
101+
102+
103+
[lexicon schemas]: https://atproto.com/guides/lexicon
104+
[at protocol]: https://atproto.com
105+
[@atproto/lexicon]: https://www.npmjs.com/package/@atproto/lexicon
106+
[aabbf43]: https://github.com/bluesky-social/atproto/blob/aabbf43a7f86b37cefbba614d408534b59f59525/packages/lexicon/src/types.ts

0 commit comments

Comments
 (0)