quicktype-core 23.0.138 → 23.0.140

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -12,6 +12,7 @@ export declare const swiftOptions: {
12
12
  justTypes: BooleanOption;
13
13
  convenienceInitializers: BooleanOption;
14
14
  explicitCodingKeys: BooleanOption;
15
+ codingKeysProtocol: StringOption;
15
16
  alamofire: BooleanOption;
16
17
  namedTypePrefix: StringOption;
17
18
  useClasses: EnumOption<boolean>;
@@ -20,6 +20,7 @@ exports.swiftOptions = {
20
20
  justTypes: new RendererOptions_1.BooleanOption("just-types", "Plain types only", false),
21
21
  convenienceInitializers: new RendererOptions_1.BooleanOption("initializers", "Generate initializers and mutators", true),
22
22
  explicitCodingKeys: new RendererOptions_1.BooleanOption("coding-keys", "Explicit CodingKey values in Codable types", true),
23
+ codingKeysProtocol: new RendererOptions_1.StringOption("coding-keys-protocol", "CodingKeys implements protocols", "protocol1, protocol2...", "", "secondary"),
23
24
  alamofire: new RendererOptions_1.BooleanOption("alamofire", "Alamofire extensions", false),
24
25
  namedTypePrefix: new RendererOptions_1.StringOption("type-prefix", "Prefix for type names", "PREFIX", "", "secondary"),
25
26
  useClasses: new RendererOptions_1.EnumOption("struct-or-class", "Structs or classes", [
@@ -75,6 +76,7 @@ class SwiftTargetLanguage extends TargetLanguage_1.TargetLanguage {
75
76
  exports.swiftOptions.dense,
76
77
  exports.swiftOptions.convenienceInitializers,
77
78
  exports.swiftOptions.explicitCodingKeys,
79
+ exports.swiftOptions.codingKeysProtocol,
78
80
  exports.swiftOptions.accessLevel,
79
81
  exports.swiftOptions.alamofire,
80
82
  exports.swiftOptions.linux,
@@ -840,7 +842,13 @@ class SwiftRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
840
842
  });
841
843
  if (!allPropertiesRedundant && c.getProperties().size > 0) {
842
844
  this.ensureBlankLine();
843
- this.emitBlock("enum CodingKeys: String, CodingKey", () => {
845
+ let enumDeclaration = this.accessLevel;
846
+ enumDeclaration += "enum CodingKeys: String, CodingKey";
847
+ if (this._options.codingKeysProtocol && this._options.codingKeysProtocol.length > 0) {
848
+ enumDeclaration += ", ";
849
+ enumDeclaration += this._options.codingKeysProtocol;
850
+ }
851
+ this.emitBlock(enumDeclaration, () => {
844
852
  for (const group of groups) {
845
853
  const { name, label } = group[0];
846
854
  if (this._options.explicitCodingKeys && label !== undefined) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "quicktype-core",
3
- "version": "23.0.138",
3
+ "version": "23.0.140",
4
4
  "description": "The quicktype engine as a library",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/index.js",