This section explains the steps that are currently used to add a new language implementation:
- Clone this repository with submodules
git clone --recurse-submodules ...
- Create a new folder named after the language
- Create a
<lang>/init.sh
script that will do the setup and, if applicable, compile and bundle the implementation - Create a
<lang>/test.sh
script that should:- read
argv[0]
read the content of the referenced file and use it as the first argument (template
) - read
argv[1]
read the content to a Map/Dictionary structure from json and use it as the second argument (substitutions
) - invoke
StdUriTemplate.expand(template, substitutions)
and return the result to std-out(tip: you can use std-err for debugging purposes), in case of exceptions, return the string "false"
- read
- Test locally the implementation by filtering one example file at the time, a suggested order would be:
./tests/test.sh <lang> spec-examples.json
./tests/test.sh <lang> spec-examples-by-section.json
./tests/test.sh <lang> extended-tests.json
./tests/test.sh <lang> negative-tests.json
- There are extended tests to cover edge cases and the correct handling of dates, in case the substitutions map contains a key "nativedate" convert it to the language native date format and run the extended tests:
./tests/test.sh <lang> edge-cases.json
- If a test doesn't pass you can easily re-run just the latest invocation by running:
./tests/re-test.sh <lang>
- Verify one last time that everything works by running
./tests/test.sh <lang>
- Add the language to the GH Action Matrix CI:
- add the language to the matrix
- add the setup with appropriate conditionals
- run it in CI to verify that everything is passing
- Add the corresponding dependabot configuration in
.github/dependabot.yml
- Add the setup to publish the implementation to a package manager or support this discussion with the repo maintainers
- Add the documentation regarding how to use the library as a dependency
The original Java implementation have been benchmarked against alternative implementations here. Now it has a rough speed comparable with more advanced and mainstream implementation without sacrificing too much on readability and portability. We do consider this the sweet spot for this project:
- fast enough to be competitive
- readable and maintainable across languages
Publishing should be fully automated and it will be performed anytime the repository is tagged on the main
branch.
Please contact the repository owners to setup the required Secrets.
A full release of all of the implementations is performed with:
./release.sh <version>
In Go and Swift is not possible to deserialize JSON into a Map preserving the order of the elements (reference). For the moment, we decided to sort the keys to have predictable results.
Make sure to format the code using dart format .
.
You can also view errors using dart analyze
.