{"id":15293530,"url":"https://github.com/soil-schema/soil","last_synced_at":"2026-02-28T04:32:20.129Z","repository":{"id":47229408,"uuid":"487752633","full_name":"soil-schema/soil","owner":"soil-schema","description":"REST api schema and code generator","archived":false,"fork":false,"pushed_at":"2022-10-26T14:45:03.000Z","size":564,"stargazers_count":1,"open_issues_count":18,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-30T14:43:09.328Z","etag":null,"topics":["rest-api","schema","swift"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/soil-schema.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-05-02T07:21:55.000Z","updated_at":"2022-09-03T11:20:32.000Z","dependencies_parsed_at":"2023-01-20T08:13:04.527Z","dependency_job_id":null,"html_url":"https://github.com/soil-schema/soil","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/soil-schema/soil","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soil-schema%2Fsoil","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soil-schema%2Fsoil/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soil-schema%2Fsoil/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soil-schema%2Fsoil/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/soil-schema","download_url":"https://codeload.github.com/soil-schema/soil/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soil-schema%2Fsoil/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29924726,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-27T19:37:42.220Z","status":"online","status_checked_at":"2026-02-28T02:00:07.010Z","response_time":90,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["rest-api","schema","swift"],"created_at":"2024-09-30T16:49:53.137Z","updated_at":"2026-02-28T04:32:20.112Z","avatar_url":"https://github.com/soil-schema.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# soil\n\nsoil is schema language for REST and JSON api and swift / kotlin client code generator.\n\n- Short schema based REST api.\n- Small and flexible code generation.\n- Write and run api testing scenarios.\n\nOther tools are more good if you want:\n\n- **Speed**: don't use JSON, use [protobuf](https://developers.google.com/protocol-buffers).\n- **GraphQL**: soil is not supporting GraphQL.\n- **Complex api**: use [Open API Schema](https://www.openapis.org/) and around tools.\n\n# .soil file\n\n## Entity\n\nYour REST resource is called `Entity` and defined by `entity` keyword in soil.\nFor example, `User` resource on your REST api can is defined with .soil file.\n\n```soil\nentity User {\n\n  field id: Integer\n  mutable field name: String\n}\n```\n\n- `entity`: start of Entity.\n- `User`: entity name.\n- `field id: Integer`: `User` entity has `id` Integer property.\n- `mutable field name: String`: `User` entity has `name` **mutable** String property.\n\nSingle .soil file can contain multiple `entity` directives.\n\n- Recipe: [Basic Entity](docs/recipes/basic-entity.md)\n\n## Endpoint\n\nEntity has mapped any endpoints on REST api.\nEach `entity` directives can contain any `endpoint` directives.\n\n```soil\nentity User {\n\n  ...\n\n  endpoint GET /users {\n    success {\n      field users: List\u003cUser\u003e\n    }\n  }\n}\n```\n\n- `endpoint GET /users`: Endpoint. This endpoint accessed by GET method and `/users` path.\n- `success` directive: successful response (status code 2xx) schema. like `entity` directive.\n- Recipe: [Basic Endpoint](docs/recipes/basic-endpoint.md)\n\n## Request and writer entity\n\nIn the REST api, most of the time there are two types of resource fields: writable and read-only.\nIn the POST and PUT methods, only the values of writable fields should be sent.\nsoil handles this difference by separating \"read-time Entity\" and \"write-time Entity\".\n\n```soil\nentity User {\n\n  field id: Integer\n  mutable field name: String\n}\n```\n\nIf entity has `mutable` or `writer` field, entity has write-time mode.\nFor example, this `User` entity exports as Swift code.\n\n```swift\npublic final class User: Decodable {\n\n    public let id: Int\n\n    public var name: String\n\n    public struct Writer: Encodable {\n\n        public let name: String\n\n        /// - Parameters:\n        ///   - name: {no comment}\n        public init(name: String) {\n            self.name = name\n        }\n    }\n}\n```\n\n`User` is read-time entity, `User.Writer` is write-time entity.\n\n## Others\n\nEach recipe presents a specific sample of soil schema detailed features.\n\n- [Field](docs/recipes/fields.md)\n- [Query](docs/recipes/query.md)\n- [Enum](docs/recipes/enum.md)\n\n# Installation\n\nsoil is written by nodejs and managed by npm.\n\n```bash\n$ npm install -g soil-schema\n```\n\n# Scenario runner\n\nsoil scneario runner helps you test REST api.\n\n```bash\n$ npx soil replay\n```\n\n## Write scenario file\n\n```soil test-scenario.soil\nscenario Test Scenario {\n  GET /sample\n}\n```\n\nsoil http request to `GET /sample` endpoint.\n\n## Parameter overrides\n\n```\nscenario Comment {\n  GET /articles/search {\n    query = Search Query Parameter\n  }\n  POST /comments {\n    body = Comment body\n  }\n}\n```\n\n## Identifier endpoint\n\nUse `id` directive in endpoint block, endpoint is identified by id string.\nYou use endpoint reference that join by dot notation entity name and endpoint id in scenario block.\n\n```soil\nentity User {\n  field id: Int\n  mutable field name: String\n\n  POST /users {\n    id register\n    request {\n      field user: User\n    }\n    success {\n      field user: User\n    }\n  }\n}\n\nscenario Register User {\n  User.register { # Actually it uses `POST /users` endpoint.\n    name = User Name\n  }\n}\n```\n\n## `api` config\n\nsoil can be configured for your REST Api in the `api` section of `soil.config.js`.\n\n|key|description|default\n|:---|:---|:---\n|api.base|Base URL for scenario runner. e.g. `https://api.example.com/v1`. Required for `replay` sub-command.|`undefined`\n|api.booleanQuery|`Boolean` type parsing and stringify strategy.|`'set-only-true'`\n|api.headers|Custom headers collection used by scenario runner.|`{}`\n\n# Code Generation\n\nYou run soil generate command in your cli with target name, export code.\n\n```\n$ npx soil generate -g [target]\n```\n\nSupported targets are:\n\n- Swift (`swift`)\n- Kotlin (`kotlin`)\n\n## Swift\n\nsoil supports Swift code generation.\nGenerated code has no dependencies, use your api request / response client class.\n\n```\n$ npx soil generate -g swift\n```\n\n### with SoilSwift package\n\nInstead of writing your own code, you can use [soil-swift](https://github.com/niaeashes/soil-swift).\n\n```js soil.config.js\nmodule.exports = {\n  swift: {\n    use: ['soil-swift'],\n  },\n}\n```\n\n## Kotlin\n\nsoil supports Kotlin code generation.\n\n```\n$ npx soil generate -g kotlin\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoil-schema%2Fsoil","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsoil-schema%2Fsoil","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoil-schema%2Fsoil/lists"}