Repository navigation
v0.6.0: parameter validation, registries, spec export and repo tooling - #7
Merged
Merged
Conversation
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018Aj3mC5LttRzqomzHWPj4M
…(v0.6.0) - Validate query, path, header and cookie parameters, coercing string values to the schema type - Add Kemal::OpenAPI::Registry so one app can serve several API descriptions; the legacy constants point at the default registry - Export the spec with KEMAL_OPENAPI_EXPORT, write_spec or spec_json - Generate operationIds for operations that lack one - register_schema_for registers nested types as $ref components - Optional response validation that logs schema mismatches - Accept `_` as a route block argument - Apply ameba fixes; add ameba as a development dependency Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018Aj3mC5LttRzqomzHWPj4M
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018Aj3mC5LttRzqomzHWPj4M
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018Aj3mC5LttRzqomzHWPj4M
erayjsx
marked this pull request as ready for review
October 14, 2026 17:48
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Requested by Eray · project thread
What does this change?
Before: only request bodies were validated, so
?page=abcreached the route. There was no way to get the spec without running the server. Every operation shared one global registry, nested types were always inlined, and the repo had no linter or contribution docs.After:
infield.KEMAL_OPENAPI_EXPORT=openapi.json crystal run src/app.crwrites the spec and exits.Kemal::OpenAPI::Registrylets one app serve several independent API descriptions.getUsersById.register_schema_for(User)registers nested types as$refcomponents, recursive types included.validate_responses: truelogs routes whose JSON responses don't match their documentation.How
Registryholds operations, schemas and security schemes, plus aversioncounter that the handler's spec cache follows.OPERATIONS,SCHEMASand the other constants are now the default registry's collections, so existing code keeps working.Validatoris now an instance bound to a registry, and the class methods take an optionalregistry:. Parameter values come fromquery_params.fetch_all,route_lookup.params, headers and cookies, and are converted to the schema type before validation.Kemal::OpenAPI.run_routerather than a proc, sonextand Kemal'shaltkeep working (there is a spec for this). They also accept_as the block argument, which ameba's autofix turned up.wsandQUERYstay undocumented because OpenAPI 3.1 cannot describe them. The README says so.How was it tested?
24 new specs, 108 total. Locally,
crystal spec,crystal tool format --check,bin/ameba, theexample/app.crbuild and a compile of every README snippet all pass on Crystal 1.19.1 and 1.22.0 with Kemal 1.14.0. I also checkedKEMAL_OPENAPI_EXPORTby hand: it writes the file and exits 0, and without it the app starts normally.Checklist
crystal specpassescrystal tool format --checkandbin/amebapass🤖 Generated with Claude Code
https://claude.ai/code/session_018Aj3mC5LttRzqomzHWPj4M
Generated by Claude Code