lapsh 0.3.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- lapsh-0.3.0/CHANGELOG.md +65 -0
- lapsh-0.3.0/LICENSE +191 -0
- lapsh-0.3.0/MANIFEST.in +4 -0
- lapsh-0.3.0/NOTICE +4 -0
- lapsh-0.3.0/PKG-INFO +297 -0
- lapsh-0.3.0/README.md +260 -0
- lapsh-0.3.0/lap/__init__.py +3 -0
- lapsh-0.3.0/lap/cli/__init__.py +1 -0
- lapsh-0.3.0/lap/cli/auth.py +118 -0
- lapsh-0.3.0/lap/cli/main.py +875 -0
- lapsh-0.3.0/lap/core/__init__.py +1 -0
- lapsh-0.3.0/lap/core/compilers/__init__.py +147 -0
- lapsh-0.3.0/lap/core/compilers/asyncapi.py +438 -0
- lapsh-0.3.0/lap/core/compilers/aws_sdk.py +363 -0
- lapsh-0.3.0/lap/core/compilers/graphql.py +529 -0
- lapsh-0.3.0/lap/core/compilers/lap_tools.py +311 -0
- lapsh-0.3.0/lap/core/compilers/lap_tools_advanced.py +112 -0
- lapsh-0.3.0/lap/core/compilers/lap_tools_parser.py +169 -0
- lapsh-0.3.0/lap/core/compilers/openapi.py +432 -0
- lapsh-0.3.0/lap/core/compilers/postman.py +445 -0
- lapsh-0.3.0/lap/core/compilers/protobuf.py +809 -0
- lapsh-0.3.0/lap/core/compilers/skill.py +427 -0
- lapsh-0.3.0/lap/core/compilers/skill_llm.py +155 -0
- lapsh-0.3.0/lap/core/compilers/smithy.py +663 -0
- lapsh-0.3.0/lap/core/converter.py +265 -0
- lapsh-0.3.0/lap/core/differ.py +261 -0
- lapsh-0.3.0/lap/core/formats/__init__.py +3 -0
- lapsh-0.3.0/lap/core/formats/lap.py +275 -0
- lapsh-0.3.0/lap/core/formats/lap_tools.py +134 -0
- lapsh-0.3.0/lap/core/parser.py +465 -0
- lapsh-0.3.0/lap/core/utils.py +60 -0
- lapsh-0.3.0/lapsh.egg-info/PKG-INFO +297 -0
- lapsh-0.3.0/lapsh.egg-info/SOURCES.txt +50 -0
- lapsh-0.3.0/lapsh.egg-info/dependency_links.txt +1 -0
- lapsh-0.3.0/lapsh.egg-info/entry_points.txt +2 -0
- lapsh-0.3.0/lapsh.egg-info/requires.txt +11 -0
- lapsh-0.3.0/lapsh.egg-info/top_level.txt +1 -0
- lapsh-0.3.0/pyproject.toml +43 -0
- lapsh-0.3.0/setup.cfg +4 -0
- lapsh-0.3.0/tests/test_agent_implementation.py +741 -0
- lapsh-0.3.0/tests/test_asyncapi_compiler.py +425 -0
- lapsh-0.3.0/tests/test_cli_auth.py +206 -0
- lapsh-0.3.0/tests/test_differ.py +228 -0
- lapsh-0.3.0/tests/test_graphql_compiler.py +423 -0
- lapsh-0.3.0/tests/test_integration.py +376 -0
- lapsh-0.3.0/tests/test_parser.py +442 -0
- lapsh-0.3.0/tests/test_postman_compiler.py +583 -0
- lapsh-0.3.0/tests/test_protobuf_compiler.py +465 -0
- lapsh-0.3.0/tests/test_roundtrip.py +161 -0
- lapsh-0.3.0/tests/test_skill_compiler.py +579 -0
- lapsh-0.3.0/tests/test_smithy_compiler.py +970 -0
- lapsh-0.3.0/tests/test_toollean.py +609 -0
lapsh-0.3.0/CHANGELOG.md
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to LAP (Lean API Platform) will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [0.3.0] - 2026-02-27
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
- Skill version override and API version surfaced in body
|
|
12
|
+
- GitHub Actions workflows for PyPI and npm publishing
|
|
13
|
+
- TypeScript SDK published as `@lap-platform/lapsh`
|
|
14
|
+
- Expanded README with concrete compression examples
|
|
15
|
+
|
|
16
|
+
### Changed
|
|
17
|
+
- CLI entry point renamed to `lapsh`
|
|
18
|
+
- All package versions aligned to 0.3.0
|
|
19
|
+
|
|
20
|
+
### Fixed
|
|
21
|
+
- Parser roundtrip failures for complex specs
|
|
22
|
+
- CLI unicode output on Windows (cp1255)
|
|
23
|
+
|
|
24
|
+
## [0.2.0] - 2026-02-13
|
|
25
|
+
|
|
26
|
+
### Added
|
|
27
|
+
- **AWS Smithy support**: Complete implementation of Smithy IDL compiler
|
|
28
|
+
- Accepts Smithy JSON AST files (`.json`)
|
|
29
|
+
- Accepts Smithy IDL files (`.smithy`) via Smithy CLI
|
|
30
|
+
- Accepts Smithy project directories with `smithy-build.json`
|
|
31
|
+
- Format auto-detection for Smithy specs
|
|
32
|
+
- Full HTTP binding extraction (@http, @httpLabel, @httpQuery, @httpHeader)
|
|
33
|
+
- Complete type system support (scalars, collections, structures, enums, maps)
|
|
34
|
+
- Auth scheme mapping (AWS SigV4, Bearer, ApiKey, HTTP Basic)
|
|
35
|
+
- Response and error schema generation
|
|
36
|
+
- 60 comprehensive tests with 100% pass rate
|
|
37
|
+
- Example Weather service in Smithy format (`examples/verbose/smithy/weather.json`)
|
|
38
|
+
- Smithy implementation documentation (`docs/smithy-implementation-summary.md`)
|
|
39
|
+
|
|
40
|
+
### Changed
|
|
41
|
+
- Updated format detection in `core/compilers/__init__.py` to include Smithy
|
|
42
|
+
- Updated CLI format choices to include "smithy"
|
|
43
|
+
- Enhanced compiler infrastructure to support protocol-agnostic IDLs
|
|
44
|
+
|
|
45
|
+
### Technical Details
|
|
46
|
+
- No new dependencies required (uses stdlib only)
|
|
47
|
+
- Optional Smithy CLI for `.smithy` file conversion
|
|
48
|
+
- Maintains backward compatibility with all existing formats
|
|
49
|
+
- Compression ratio: ~2.3x (standard), ~2.9x (lean) for Smithy specs
|
|
50
|
+
|
|
51
|
+
## [0.1.0] - 2025-01-15
|
|
52
|
+
|
|
53
|
+
### Added
|
|
54
|
+
- Initial release of LAP (Lean API Platform)
|
|
55
|
+
- Support for OpenAPI/Swagger specs
|
|
56
|
+
- Support for GraphQL schemas (SDL and introspection JSON)
|
|
57
|
+
- Support for AsyncAPI specs
|
|
58
|
+
- Support for Protocol Buffers (.proto files)
|
|
59
|
+
- Support for Postman collections
|
|
60
|
+
- CLI with compile, validate, convert, diff, and benchmark commands
|
|
61
|
+
- LAP format v0.3 with @common_fields directive
|
|
62
|
+
- Token counting and compression metrics
|
|
63
|
+
- Integration with LangChain, CrewAI, OpenAI
|
|
64
|
+
- Python SDK
|
|
65
|
+
- Comprehensive test suite (800+ tests)
|
lapsh-0.3.0/LICENSE
ADDED
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to the Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by the Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding any notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
Copyright 2025 Lean API Platform Contributors
|
|
180
|
+
|
|
181
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
182
|
+
you may not use this file except in compliance with the License.
|
|
183
|
+
You may obtain a copy of the License at
|
|
184
|
+
|
|
185
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
186
|
+
|
|
187
|
+
Unless required by applicable law or agreed to in writing, software
|
|
188
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
189
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
190
|
+
See the License for the specific language governing permissions and
|
|
191
|
+
limitations under the License.
|
lapsh-0.3.0/MANIFEST.in
ADDED
lapsh-0.3.0/NOTICE
ADDED
lapsh-0.3.0/PKG-INFO
ADDED
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: lapsh
|
|
3
|
+
Version: 0.3.0
|
|
4
|
+
Summary: Lean API Platform -- Token-efficient API specs for AI agents
|
|
5
|
+
Author: LAP Contributors
|
|
6
|
+
License-Expression: Apache-2.0
|
|
7
|
+
Project-URL: Homepage, https://github.com/Lap-Platform/lap
|
|
8
|
+
Project-URL: Documentation, https://github.com/Lap-Platform/lap#readme
|
|
9
|
+
Project-URL: Repository, https://github.com/Lap-Platform/lap
|
|
10
|
+
Project-URL: Issues, https://github.com/Lap-Platform/lap/issues
|
|
11
|
+
Project-URL: Changelog, https://github.com/Lap-Platform/lap/blob/main/CHANGELOG.md
|
|
12
|
+
Keywords: api,openapi,ai,llm,agents,compression,platform
|
|
13
|
+
Classifier: Development Status :: 4 - Beta
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
21
|
+
Classifier: Topic :: Software Development :: Documentation
|
|
22
|
+
Requires-Python: >=3.10
|
|
23
|
+
Description-Content-Type: text/markdown
|
|
24
|
+
License-File: LICENSE
|
|
25
|
+
License-File: NOTICE
|
|
26
|
+
Requires-Dist: pyyaml>=6.0
|
|
27
|
+
Requires-Dist: tiktoken>=0.5.0
|
|
28
|
+
Provides-Extra: dev
|
|
29
|
+
Requires-Dist: pytest; extra == "dev"
|
|
30
|
+
Requires-Dist: pytest-timeout; extra == "dev"
|
|
31
|
+
Requires-Dist: rich; extra == "dev"
|
|
32
|
+
Requires-Dist: graphql-core; extra == "dev"
|
|
33
|
+
Requires-Dist: tiktoken; extra == "dev"
|
|
34
|
+
Requires-Dist: build; extra == "dev"
|
|
35
|
+
Requires-Dist: twine; extra == "dev"
|
|
36
|
+
Dynamic: license-file
|
|
37
|
+
|
|
38
|
+
<div align="center">
|
|
39
|
+
|
|
40
|
+
# LAP — Lean API Platform
|
|
41
|
+
|
|
42
|
+
**Cut API spec tokens by 10×. Same information. Fraction of the cost.**
|
|
43
|
+
|
|
44
|
+
[](https://pypi.org/project/lapsh/)
|
|
45
|
+
[](https://github.com/Lap-Platform/lap/actions/workflows/ci.yml)
|
|
46
|
+
[](LICENSE)
|
|
47
|
+
[](https://www.python.org/downloads/)
|
|
48
|
+
|
|
49
|
+
LAP compiles API specs into **LAP** — a typed, token-efficient format built for AI agents.
|
|
50
|
+
OpenAPI, GraphQL, AsyncAPI, Protobuf, Postman, Smithy → one compact format.
|
|
51
|
+
|
|
52
|
+
</div>
|
|
53
|
+
|
|
54
|
+
## Why LAP?
|
|
55
|
+
|
|
56
|
+
LLMs waste thousands of tokens parsing bloated API specs. Stripe's OpenAPI spec is **1M+ tokens** — mostly boilerplate. LAP strips what agents don't need and keeps everything they do.
|
|
57
|
+
|
|
58
|
+
- **10.3× overall compression** across 162 real-world specs
|
|
59
|
+
- **Up to 39.6×** on large OpenAPI specs (Notion, Snyk, Zoom)
|
|
60
|
+
- **Zero information loss** — every endpoint, param, and type constraint preserved
|
|
61
|
+
- **6 formats supported** — one CLI, one output format
|
|
62
|
+
|
|
63
|
+

|
|
64
|
+
|
|
65
|
+
## Quick Start
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
# Python
|
|
69
|
+
pip install lapsh
|
|
70
|
+
lapsh compile api.yaml -o api.lap
|
|
71
|
+
|
|
72
|
+
# Node.js (no install needed)
|
|
73
|
+
npx @lap-platform/lapsh compile api.yaml -o api.lap
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Before / After
|
|
77
|
+
|
|
78
|
+
**OpenAPI (26 lines):**
|
|
79
|
+
```yaml
|
|
80
|
+
paths:
|
|
81
|
+
/v1/charges:
|
|
82
|
+
post:
|
|
83
|
+
summary: Create a charge
|
|
84
|
+
requestBody:
|
|
85
|
+
required: true
|
|
86
|
+
content:
|
|
87
|
+
application/json:
|
|
88
|
+
schema:
|
|
89
|
+
type: object
|
|
90
|
+
required: [amount, currency]
|
|
91
|
+
properties:
|
|
92
|
+
amount:
|
|
93
|
+
type: integer
|
|
94
|
+
description: Amount in cents
|
|
95
|
+
currency:
|
|
96
|
+
type: string
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
**LAP (2 lines):**
|
|
100
|
+
```
|
|
101
|
+
## POST /v1/charges — Create a charge
|
|
102
|
+
@required {amount: int # in cents, currency: str(ISO4217)}
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## Benchmarks
|
|
106
|
+
|
|
107
|
+
162 specs · 5,228 endpoints · 4.37M → 423K tokens
|
|
108
|
+
|
|
109
|
+
| Format | Specs | Median | Best |
|
|
110
|
+
|--------|------:|-------:|-----:|
|
|
111
|
+
| **OpenAPI** | 30 | **5.2×** | 39.6× |
|
|
112
|
+
| **Postman** | 36 | **6.1×** | 18.0× |
|
|
113
|
+
| **AsyncAPI** | 31 | **2.2×** | 14.0× |
|
|
114
|
+
| **Protobuf** | 35 | **1.8×** | 117.4× |
|
|
115
|
+
| **GraphQL** | 30 | **1.4×** | 2.1× |
|
|
116
|
+
|
|
117
|
+

|
|
118
|
+
|
|
119
|
+
→ [Full benchmark results](BENCHMARKS.md)
|
|
120
|
+
|
|
121
|
+
## How It Works
|
|
122
|
+
|
|
123
|
+

|
|
124
|
+
|
|
125
|
+
LAP compiles API specs through five stages. Here's each one applied to the Stripe charges example above:
|
|
126
|
+
|
|
127
|
+
**1. Structural noise removal (~30%)**
|
|
128
|
+
Strip YAML scaffolding -- nested `paths:`, `requestBody:`, `content:`, `application/json:`, `schema:` wrappers all vanish:
|
|
129
|
+
|
|
130
|
+
```yaml
|
|
131
|
+
# Before: 6 levels of nesting just to reach the schema
|
|
132
|
+
paths:
|
|
133
|
+
/v1/charges:
|
|
134
|
+
post:
|
|
135
|
+
requestBody:
|
|
136
|
+
content:
|
|
137
|
+
application/json:
|
|
138
|
+
schema:
|
|
139
|
+
properties: ...
|
|
140
|
+
|
|
141
|
+
# After: endpoint + params on flat lines
|
|
142
|
+
## POST /v1/charges — Create a charge
|
|
143
|
+
@required {amount: int, currency: str}
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
**2. Directive grammar (~25%)**
|
|
147
|
+
`@directives` replace deeply nested YAML structures with single-line declarations:
|
|
148
|
+
|
|
149
|
+
```yaml
|
|
150
|
+
# Before # After
|
|
151
|
+
responses: @returns(200) {id: str, amount: int, status: str}
|
|
152
|
+
'200': @errors {400, 401, 402}
|
|
153
|
+
content:
|
|
154
|
+
application/json:
|
|
155
|
+
schema:
|
|
156
|
+
properties:
|
|
157
|
+
id: {type: string}
|
|
158
|
+
amount: {type: integer}
|
|
159
|
+
status: {type: string}
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
**3. Type compression (~10%)**
|
|
163
|
+
Verbose OpenAPI type declarations become inline type expressions:
|
|
164
|
+
|
|
165
|
+
```
|
|
166
|
+
type: string, format: uuid -> str(uuid)
|
|
167
|
+
type: integer -> int
|
|
168
|
+
type: array, items: {type: str} -> [str]
|
|
169
|
+
type: string, enum: [a, b, c] -> enum(a|b|c)
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
**4. Redundancy elimination (~20%)**
|
|
173
|
+
Shared fields across endpoints are extracted once via `@common_fields` instead of repeated per-endpoint:
|
|
174
|
+
|
|
175
|
+
```
|
|
176
|
+
# Before: {id: str, created: int, object: str} repeated in every @returns
|
|
177
|
+
# After:
|
|
178
|
+
@common_fields {id: str, created: int(unix-timestamp), object: str}
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
**5. Description stripping -- lean mode (~15%)**
|
|
182
|
+
LLMs infer meaning from parameter names. Strip descriptions for further savings:
|
|
183
|
+
|
|
184
|
+
```
|
|
185
|
+
# Standard: @required {amount: int # Amount in cents., currency: str # ISO 4217 code.}
|
|
186
|
+
# Lean: @required {amount: int, currency: str}
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
## LAP Format Conventions
|
|
190
|
+
|
|
191
|
+
LAP uses `@directives` — a flat, line-oriented grammar designed for LLM parsing.
|
|
192
|
+
|
|
193
|
+
### Header Directives
|
|
194
|
+
|
|
195
|
+
| Directive | Purpose | Example |
|
|
196
|
+
|-----------|---------|---------|
|
|
197
|
+
| `@lap` | Format version | `@lap v0.3` |
|
|
198
|
+
| `@api` | API name | `@api Stripe Charges API` |
|
|
199
|
+
| `@base` | Base URL | `@base https://api.stripe.com` |
|
|
200
|
+
| `@version` | API version | `@version 2024-12-18` |
|
|
201
|
+
| `@auth` | Auth scheme | `@auth Bearer bearer` |
|
|
202
|
+
| `@endpoints` | Total endpoint count | `@endpoints 5` |
|
|
203
|
+
| `@toc` | Table of contents | `@toc charges(5)` |
|
|
204
|
+
| `@end` | End of document | `@end` |
|
|
205
|
+
|
|
206
|
+
### Endpoint Directives
|
|
207
|
+
|
|
208
|
+
| Directive | Purpose | Example |
|
|
209
|
+
|-----------|---------|---------|
|
|
210
|
+
| `@endpoint` | Method + path | `@endpoint POST /v1/charges` |
|
|
211
|
+
| `@desc` | Description (standard mode) | `@desc Create a charge` |
|
|
212
|
+
| `@required` | Required params with types | `@required {amount: int, currency: str}` |
|
|
213
|
+
| `@optional` | Optional params with types | `@optional {limit: int=10, cursor: str}` |
|
|
214
|
+
| `@returns(code)` | Response schema | `@returns(200) {id: str, status: str}` |
|
|
215
|
+
| `@errors` | Error codes | `@errors {400, 401, 404}` |
|
|
216
|
+
|
|
217
|
+
### Type System
|
|
218
|
+
|
|
219
|
+
| Type | Meaning | Example |
|
|
220
|
+
|------|---------|---------|
|
|
221
|
+
| `str` | String | `name: str` |
|
|
222
|
+
| `int` | Integer | `amount: int` |
|
|
223
|
+
| `bool` | Boolean | `capture: bool` |
|
|
224
|
+
| `float` | Float | `price: float` |
|
|
225
|
+
| `map` | Object/dict | `metadata: map` |
|
|
226
|
+
| `[T]` | Array of T | `items: [str]` |
|
|
227
|
+
| `T?` | Nullable | `email: str?` |
|
|
228
|
+
| `str(format)` | Typed string | `id: str(uuid)` |
|
|
229
|
+
| `int(format)` | Typed int | `created: int(unix-timestamp)` |
|
|
230
|
+
| `enum(a\|b\|c)` | Enum values | `status: enum(active\|inactive)` |
|
|
231
|
+
| `T=default` | Default value | `limit: int=10` |
|
|
232
|
+
| `map{k: T}` | Typed object | `billing: map{name: str, email: str}` |
|
|
233
|
+
|
|
234
|
+
### Standard vs Lean Mode
|
|
235
|
+
|
|
236
|
+
- **Standard** — includes `@desc` and inline `# comments` after fields
|
|
237
|
+
- **Lean** — strips descriptions and comments; LLMs infer meaning from param names
|
|
238
|
+
|
|
239
|
+
```
|
|
240
|
+
# Standard: @required {amount: int # Amount in cents., currency: str # ISO 4217 code.}
|
|
241
|
+
# Lean: @required {amount: int, currency: str}
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
### Example (Lean)
|
|
245
|
+
|
|
246
|
+
```
|
|
247
|
+
@lap v0.3
|
|
248
|
+
@api Stripe Charges API
|
|
249
|
+
@base https://api.stripe.com
|
|
250
|
+
@auth Bearer bearer
|
|
251
|
+
|
|
252
|
+
@endpoint POST /v1/charges
|
|
253
|
+
@required {amount: int, currency: str}
|
|
254
|
+
@optional {source: str, customer: str, metadata: map}
|
|
255
|
+
@returns(200) {id: str, amount: int, status: str, paid: bool}
|
|
256
|
+
@errors {400, 401, 402}
|
|
257
|
+
|
|
258
|
+
@endpoint GET /v1/charges/{charge}
|
|
259
|
+
@required {charge: str}
|
|
260
|
+
@returns(200)
|
|
261
|
+
@errors {404}
|
|
262
|
+
|
|
263
|
+
@end
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
## Supported Formats
|
|
267
|
+
|
|
268
|
+
```bash
|
|
269
|
+
lapsh compile api.yaml # OpenAPI 3.x / Swagger
|
|
270
|
+
lapsh compile schema.graphql # GraphQL SDL
|
|
271
|
+
lapsh compile events.yaml # AsyncAPI
|
|
272
|
+
lapsh compile service.proto # Protobuf / gRPC
|
|
273
|
+
lapsh compile collection.json # Postman v2.1
|
|
274
|
+
lapsh compile model.json # AWS Smithy (JSON AST or .smithy)
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
## Python SDK
|
|
278
|
+
|
|
279
|
+
```python
|
|
280
|
+
from lap import LAPClient
|
|
281
|
+
|
|
282
|
+
doc = LAPClient().compile("api.yaml")
|
|
283
|
+
for ep in doc.endpoints:
|
|
284
|
+
print(f"{ep.method} {ep.path}")
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
## Also: LAP
|
|
288
|
+
|
|
289
|
+
Companion format for **tool manifests** (MCP servers, function definitions). Same philosophy: typed, compact, zero ambiguity.
|
|
290
|
+
|
|
291
|
+
## Contributing
|
|
292
|
+
|
|
293
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
|
|
294
|
+
|
|
295
|
+
## License
|
|
296
|
+
|
|
297
|
+
Apache 2.0 — See [LICENSE](LICENSE)
|