Commit Graph

188 Commits

Author SHA1 Message Date
Johann Schopplich
6e9519db3a refactor: remove unused comments 2025-11-03 08:19:57 +01:00
Wind
e414ca3671 fix: handle empty list items and nested objects in list items (#65)
* fix: support quoted keys with array syntax

Fixes parsing of quoted keys followed by array syntax like:
"x-codeSamples"[1]{lang,label,source}:

Previously, parseArrayHeaderLine would skip any line starting with
a quoted key. This caused large OpenAPI specs (like Hetzner Cloud API)
to fail decoding.

Changes:
- Modified parseArrayHeaderLine to handle quoted keys
- Added logic to find bracket start after closing quote
- Unescape quoted keys properly
- Added 3 test cases for the new functionality

Closes #62

* fix: handle empty list items and nested objects in list items

This commit fixes two critical decoder bugs that prevented complex
OpenAPI specs (like DigitalOcean's 638 schemas) from being decoded:

1. Empty list items: Items encoded as just `-` (without space) were
   not recognized. The decoder only checked for `LIST_ITEM_PREFIX = '- '`.
   Fixed by adding check for both `- ` and `-` patterns.

2. Nested objects in list items: When a list item contains an object
   with nested properties (e.g., `allOf[2]: - properties: state: ...`),
   the decoder was looking for nested content at the wrong depth level.
   List items add one level of indentation, so nested content should be
   at baseDepth + 2, not baseDepth + 1.

   Fixed by creating `decodeKeyValueForListItem()` that correctly handles
   the extra nesting while maintaining proper followDepth for siblings.

Changes:
- Added `decodeKeyValueForListItem()` function to handle list item nesting
- Updated `decodeObjectFromListItem()` to use new function
- Added empty item detection in `decodeListArray()`
- Added comprehensive unit tests for both bugs
- Added integration test with real DigitalOcean OpenAPI spec (638 schemas)
- Gitignored large fixture files, added README with download instructions

Tests:
- 5 new unit tests in list-item-bugs.test.ts
- 1 integration test in digitalocean-decode.test.ts (skips if fixture missing)
- All 309 existing tests still pass

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* perf: calculate depth on demand

* chore: move tests to test suite

* chore: test against new tests

---------

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Johann Schopplich <mail@johannschopplich.com>
2025-11-03 08:18:14 +01:00
Johann Schopplich
cfc3dadb21 docs: update gray color 2025-11-03 08:03:47 +01:00
Johann Schopplich
244429dc8f ci: fix fetch depth for changelog generation 2025-11-02 21:54:59 +01:00
Johann Schopplich
cf31d1087d ci: fix fetch depth for changelog generation 2025-11-02 21:49:40 +01:00
Morteza Hosseini
c3db2a138c ci: update CI configuration for improved caching and dependency management (#63)
* build: update CI configuration for improved caching and dependency management

* build: ensure newline at end of file in CI configuration
2025-11-02 18:49:00 +01:00
Johann Schopplich
c1527dcf80 chore: fix type issue 2025-11-02 18:34:00 +01:00
Johann Schopplich
8977c8c7d6 feat: use language-agnostic test suite 2025-11-02 18:31:06 +01:00
Johann Schopplich
662a9d4bc5 feat: move SPEC to @toon-format/spec 2025-11-02 18:30:36 +01:00
David Sancho
7bb5dfb10c docs: add OCaml implementation (#57) 2025-11-01 22:15:32 +01:00
Johann Schopplich
da0a0b9be3 chore: release v0.7.0 2025-11-01 17:28:24 +01:00
Johann Schopplich
5f09a14c61 chore: fix type issues 2025-11-01 17:15:37 +01:00
Johann Schopplich
0710bd19e7 feat!: publish to @toon-format/toon and @toon-format/cli 2025-11-01 16:53:41 +01:00
Johann Schopplich
8bcbdb7315 docs: enhance explanation for TOON format benefits (related to #49) 2025-11-01 07:53:48 +01:00
Johann Schopplich
b8140ce053 chore: release v0.6.0 2025-11-01 00:37:53 +01:00
Johann Schopplich
8567df9131 fix(cli): inline tokenx 2025-11-01 00:37:11 +01:00
SangheeSon
2b882870f7 feat(cli): add --stats flag to show token savings (#51)
* feat(cli): add --stats flag to show token efficiency

- Add --stats boolean flag to display token count comparison
- Calculate approximate tokens using char length / 4 heuristic
- Show JSON vs TOON token counts with savings percentage
- Opt-in feature, default behavior unchanged

* feat: use tokenx for more accurate estimates

---------

Co-authored-by: Johann Schopplich <mail@johannschopplich.com>
2025-11-01 00:35:54 +01:00
Anton Maminov
af068f995d docs: add Crystal implementation (#48) 2025-11-01 00:26:43 +01:00
Johann Schopplich
901fcc53f3 docs(spec): add main title 2025-10-31 22:13:20 +01:00
Morteza Hosseini
baf450b46c docs: update README with badges for CI, npm version, spec, downloads, and license (#52) 2025-10-31 19:48:54 +01:00
Johann Schopplich
5a2040ae81 docs(spec): release v1.3 2025-10-31 13:52:18 +01:00
Johann Schopplich
617e5f1bda docs(spec): more work on v1.3 draft 2025-10-31 13:23:55 +01:00
Johann Schopplich
9f926c4de1 docs(spec): v1.3 draft 2025-10-31 13:13:02 +01:00
Johann Schopplich
bb1f61030e test: add test for precision preservation of repeating decimals 2025-10-31 12:40:15 +01:00
Johann Schopplich
bf592b0bba docs(spec): better RFC/W3C compliance 2025-10-31 12:06:24 +01:00
Johann Schopplich
8c8c654a32 docs(spec): update acknowledgments and license section 2025-10-31 11:50:45 +01:00
Johann Schopplich
fe8f0615df docs: merge installation and quick start 2025-10-31 09:27:31 +01:00
Johann Schopplich
13351a365a docs: add rtoon as Rust implementation (closes #41) 2025-10-31 09:10:22 +01:00
Johann Schopplich
a3bf1965c6 docs: add implementation note 2025-10-31 09:04:19 +01:00
Johann Schopplich
753ee2cefd docs: add table of contents 2025-10-31 08:56:42 +01:00
Johann Schopplich
b2eeaea9d0 docs: add Gleam port (fixes #44) 2025-10-30 21:58:14 +01:00
Johann Schopplich
3a48cd4c7c docs: add Dart port (fixes #42) 2025-10-30 21:57:03 +01:00
Johann Schopplich
66212285e5 refactor(cli): re-use source constants 2025-10-30 21:33:08 +01:00
Johann Schopplich
7317b869b1 docs: update benchmark README 2025-10-30 17:38:00 +01:00
Johann Schopplich
983728e913 refactor: progress bar configuration 2025-10-30 15:24:22 +01:00
Johann Schopplich
fb43bdf527 docs: adjust padding for benchmark comparison 2025-10-30 15:19:16 +01:00
Johann Schopplich
2c4f3c4362 test: add benchmarks for compact vs. pretty JSON 2025-10-30 15:02:51 +01:00
Johann Schopplich
df68417d8b docs: remove redundant canonical formatting rules section 2025-10-30 12:45:16 +01:00
Johann Schopplich
858797f186 docs: update social card image 2025-10-30 12:45:00 +01:00
Johann Schopplich
b93714e9b9 refactor: move gpt-tokenizer to benchmarks 2025-10-30 09:27:11 +01:00
Johann Schopplich
752118d1b5 docs: update Python library links 2025-10-30 09:18:01 +01:00
Johann Schopplich
79cebbdf15 docs: update decode example 2025-10-30 09:15:37 +01:00
Johann Schopplich
f0f1166e20 chore: release v0.5.1 2025-10-30 08:35:38 +01:00
Johann Schopplich
e41b846ea2 fix: add missing bin entry for toon CLI 2025-10-30 08:35:34 +01:00
Johann Schopplich
963c618f75 chore: release v0.5.0 2025-10-30 08:09:30 +01:00
Andreas Partsch
80acc9d4fe feat: add cli (#34)
* feat: add cli for toon

* docs: use npx in the readme

* feat: overhaul and refactor

---------

Co-authored-by: Johann Schopplich <mail@johannschopplich.com>
2025-10-30 08:08:08 +01:00
highpofly.eth
28896e19e8 docs: add Rust port (#36)
* added the rust port to the list of ports in the readme

* chore: consolidate

---------

Co-authored-by: JadJabbour <–jabbourj.87@gmail.com>
Co-authored-by: Johann Schopplich <mail@johannschopplich.com>
2025-10-30 08:07:31 +01:00
Johann Schopplich
19570fc36d docs: move playground tip 2025-10-29 21:15:16 +01:00
Johann Schopplich
8aa40f5ac9 docs: playground by @curiouslychase (closes #32) 2025-10-29 20:50:14 +01:00
Ivan Starkov
40c053e7ca docs: fix custom toon syntax (#33) 2025-10-29 20:43:36 +01:00