Generates a Swift file for every source file, creating types and optionally initializers and decoders for the corresponding JSON structures.
Options are provided as an object to the renderer function.
addConformances
- Description: Conformances to add to generated types.
- Required: no
- Type:
ConformanceOptions[]
- Default:
[]
convertIdentifiersToNamingConvention
- Description: If generated type and member names’ casing should be converted to Swift conventions.
- Required: no
- Type:
boolean
- Default:
false
decodableSynthesization
- Description: If generated
struct
types should haveDecodable
conformances. - Required: no
- Type:
DecodableSynthesizationOptions
- Default:
undefined
- Description: If generated
defaultPublic
- Description: If generated types and members should be
public
. - Required: no
- Type:
boolean
- Default:
false
- Description: If generated types and members should be
forceConstantStructMembers
- Description: If
struct
members are always generated aslet
. This ignores theisReadOnly
AST flag. - Required: no
- Type:
boolean
- Default:
false
- Description: If
generateStructInitializers
- Description: If generated
struct
types should have initializers generated. Initializers will have defaultnil
values for optional members. - Required: no
- Type:
boolean
- Default:
false
- Description: If generated
packageName
- Description: The package name to use in all file comments.
- Required: yes
- Type:
string
- Default: —
discriminatorKey
- Description: For enumerations with associated values, the key of the discriminator property.
- Required: yes
- Type:
string
- Default: —
identifier
- Description: The identifier of the type to add.
- Required: yes
- Type:
string | (( node: RecordNode | UnionNode | EnumerationNode | TypeParameterNode ) => string)
- Default: —
includesDecodable
- Description: If the type includes
Decodable
conformance, which will not add an additionalDecodable
conformance ifdecodableSynthesization
is used. - Required: no
- Type:
boolean
- Default:
false
- Description: If the type includes
forMainTypes
- Description: If set, whether the type is only for main types (
true
) or sub types (false
). - Required: no
- Type:
boolean
- Default:
undefined
- Description: If set, whether the type is only for main types (
JSDoc | Swift |
---|---|
Description | Documentation comment |
@title |
— |
@default |
— |
@deprecated |
Deprecation annotation |
@markdown |
— |
@minLength |
— |
@maxLength |
— |
@pattern |
— |
@format |
— |
@integer |
Type: Int |
@minimum |
— |
@maximum |
— |
@exclusiveMinimum |
— |
@exclusiveMaximum |
— |
@multipleOf |
— |
@minItems |
— |
@maxItems |
— |
@uniqueItems |
— |
@minProperties |
— |
@maxProperties |
— |
@patternProperties |
— |
readonly modifier |
let variable member |