@basketry/sorbet
Advanced tools
Comparing version 0.0.5 to 0.0.6
{ | ||
"name": "@basketry/sorbet", | ||
"version": "0.0.5", | ||
"version": "0.0.6", | ||
"description": "Basketry generator for generating Sorbet types and interfaces", | ||
@@ -51,3 +51,3 @@ "main": "./lib/index.js", | ||
"dependencies": { | ||
"basketry": "^0.0.16", | ||
"basketry": "^0.0.17", | ||
"case": "^1.6.3", | ||
@@ -54,0 +54,0 @@ "prettier": "^2.5.1" |
222
README.md
@@ -6,3 +6,3 @@ [![main](https://github.com/basketry/sorbet/workflows/build/badge.svg?branch=main&event=push)](https://github.com/basketry/sorbet/actions?query=workflow%3Abuild+branch%3Amain+event%3Apush) | ||
[Basketry generator](https://github.com/basketry/basketry) for generating [Sorbet](https://sorbet.org/) types and interfaces. This parser can be coupled with any Basketry parser. | ||
[Basketry generator](https://github.com/basketry) for generating [Sorbet](https://sorbet.org/) types and interfaces. This parser can be coupled with any Basketry parser. | ||
@@ -19,2 +19,222 @@ ## Quick Start | ||
## Folder Structure | ||
This generator emits a folder structure suitable for loading classes with [Zeitwerk](https://github.com/fxn/zeitwerk). All files are written to the `/{title}/v{majorVersion}` subfolder within the output directory. The default structure can be customized using various options. | ||
Example config without options: | ||
```json | ||
{ | ||
"source": "petstore.json", | ||
"parser": "@basketry/swagger-2", | ||
"generators": ["@basketry/sorbet"], | ||
"output": "src" | ||
} | ||
``` | ||
Resulting output: | ||
``` | ||
my_project/ | ||
├─ src/ | ||
│ ├─ petstore/ | ||
│ │ ├─ v1/ | ||
│ │ │ ├─ some_enum_a.rb | ||
│ │ │ ├─ some_enum_b.rb | ||
│ │ │ ├─ some_interface_a.rb | ||
│ │ │ ├─ some_interface_b.rb | ||
│ │ │ ├─ some_type_a.rb | ||
│ │ │ ├─ some_type_b.rb | ||
│ ├─ .gitattributes | ||
├─ basketry.config.json | ||
├─ petstore.json | ||
``` | ||
## Options | ||
All sorbet generator options are namespaced within a `sorbet` property as shown in the following example config: | ||
```json | ||
{ | ||
"source": "petstore.json", | ||
"parser": "@basketry/swagger-2", | ||
"generators": [ | ||
{ | ||
"rule": "@basketry/sorbet", | ||
"options": { | ||
"sorbet": { | ||
"includeVersion": false, | ||
"typesModule": "types", | ||
"enumsModule": "enums", | ||
"interfacesModule": "services", | ||
"types": { | ||
"number": "BigDecimal" | ||
} | ||
} | ||
} | ||
} | ||
], | ||
"output": "src" | ||
} | ||
``` | ||
### `includeVersion` | ||
This option controls whether or not the files will be written into a `/v{majorVersion}` subfolder. The default is `true`. | ||
Example usage: | ||
```json | ||
{ | ||
"rule": "@basketry/sorbet", | ||
"options": { | ||
"sorbet": { | ||
"includeVersion": false | ||
} | ||
} | ||
} | ||
``` | ||
Resulting output: | ||
``` | ||
my_project/ | ||
├─ src/ | ||
│ ├─ petstore/ | ||
│ │ ├─ some_enum_a.rb | ||
│ │ ├─ some_enum_b.rb | ||
│ │ ├─ some_interface_a.rb | ||
│ │ ├─ some_interface_b.rb | ||
│ │ ├─ some_type_a.rb | ||
│ │ ├─ some_type_b.rb | ||
│ ├─ .gitattributes | ||
├─ basketry.config.json | ||
├─ petstore.json | ||
``` | ||
### `typesModule` | ||
This option allows you to specify the sub-folder (and sub-module) for the emitted types. If this option is not supplied, types are written into the main project output folder. | ||
```json | ||
{ | ||
"rule": "@basketry/sorbet", | ||
"options": { | ||
"sorbet": { | ||
"typesModule": "types" | ||
} | ||
} | ||
} | ||
``` | ||
Resulting output: | ||
``` | ||
my_project/ | ||
├─ src/ | ||
│ ├─ petstore/ | ||
│ │ ├─ v1/ | ||
│ │ │ ├─ types/ | ||
│ │ │ │ ├─ some_type_a.rb | ||
│ │ │ │ ├─ some_type_b.rb | ||
│ │ │ ├─ some_enum_a.rb | ||
│ │ │ ├─ some_enum_b.rb | ||
│ │ │ ├─ some_interface_a.rb | ||
│ │ │ ├─ some_interface_b.rb | ||
│ ├─ .gitattributes | ||
├─ basketry.config.json | ||
├─ petstore.json | ||
``` | ||
### `enumsModule` | ||
This option allows you to specify the sub-folder (and sub-module) for the emitted types. If this option is not supplied, enums are written into the main project output folder. | ||
```json | ||
{ | ||
"rule": "@basketry/sorbet", | ||
"options": { | ||
"sorbet": { | ||
"enumsModule": "enums" | ||
} | ||
} | ||
} | ||
``` | ||
Resulting output: | ||
``` | ||
my_project/ | ||
├─ src/ | ||
│ ├─ petstore/ | ||
│ │ ├─ v1/ | ||
│ │ │ ├─ enums/ | ||
│ │ │ │ ├─ some_enum_a.rb | ||
│ │ │ │ ├─ some_enum_b.rb | ||
│ │ │ ├─ some_interface_a.rb | ||
│ │ │ ├─ some_interface_b.rb | ||
│ │ │ ├─ some_type_a.rb | ||
│ │ │ ├─ some_type_b.rb | ||
│ ├─ .gitattributes | ||
├─ basketry.config.json | ||
├─ petstore.json | ||
``` | ||
### `interfacesModule` | ||
This option allows you to specify the sub-folder (and sub-module) for the emitted types. If this option is not supplied, interfaces are written into the main project output folder. | ||
```json | ||
{ | ||
"rule": "@basketry/sorbet", | ||
"options": { | ||
"sorbet": { | ||
"interfacesModule": "services" | ||
} | ||
} | ||
} | ||
``` | ||
Resulting output: | ||
``` | ||
my_project/ | ||
├─ src/ | ||
│ ├─ petstore/ | ||
│ │ ├─ v1/ | ||
│ │ │ ├─ services/ | ||
│ │ │ │ ├─ some_interface_a.rb | ||
│ │ │ │ ├─ some_interface_b.rb | ||
│ │ │ ├─ some_enum_a.rb | ||
│ │ │ ├─ some_enum_b.rb | ||
│ │ │ ├─ some_type_a.rb | ||
│ │ │ ├─ some_type_b.rb | ||
│ ├─ .gitattributes | ||
├─ basketry.config.json | ||
├─ petstore.json | ||
``` | ||
### `types` | ||
This option allows you to specify overrides for various types. | ||
The following example will cause the generator to emit `BigDecimal` (instead of the default `Numeric`) for the type `number`. Multiple type overrides may be specified. | ||
```json | ||
{ | ||
"rule": "@basketry/sorbet", | ||
"options": { | ||
"sorbet": { | ||
"types": { | ||
"number": "BigDecimal" | ||
} | ||
} | ||
} | ||
} | ||
``` | ||
## Snapshots | ||
An example of generated sorbet code can be found as a test snapshot at [`/src/snapshot/`](./src/snapshot/). | ||
--- | ||
@@ -21,0 +241,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
40354
267
+ Addedbasketry@0.0.17(transitive)
- Removedbasketry@0.0.16(transitive)
Updatedbasketry@^0.0.17