Skip to content
This repository was archived by the owner on Apr 20, 2024. It is now read-only.

Commit afe028d

Browse files
Merge pull request #27 from nodes-vapor/hotfix/misc-fixes
Align line breaks, use bools and unique fallback
2 parents 629ecbc + 0e1ae40 commit afe028d

5 files changed

Lines changed: 3 additions & 8 deletions

File tree

Controllers/RouteCollection.stencil

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
{% for type in types.all|!protocol|annotated:"controller" %}
44
// sourcery:file:Routes/{{ type.localName }}/{{ type.localName }}+RouteCollection.generated.swift
5-
65
import Vapor
76

87
extension {{ type.localName }}: RouteCollection {

Models/JSONConvertible.stencil

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
{% for type in types.based.Model|!protocol|annotated:"model"|!annotated:"ignoreJSONConvertible" %}
44
// sourcery:file:Models/{{ type.localName }}/{{ type.localName }}+JSONConvertible.generated.swift
5-
65
import Vapor
76
import Fluent
87
{% if type.annotations.import %}
@@ -14,7 +13,7 @@ import {{ var }}
1413
{% endif %}
1514

1615
extension {{ type.localName }}: JSONConvertible {
17-
internal enum JSONKeys: String {
16+
internal enum JSONKeys {
1817
{% for var in type.storedVariables|!annotated:"ignore"|!annotated:"ignoreJSONConvertible" %}
1918
static let {{ var.annotations.jsonKey|default:var.name }} = "{{ var.annotations.jsonKey|default:var.name }}"
2019
{% endfor %}

Models/NodeRepresentable.stencil

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
{% for type in types.based.Model|!protocol|annotated:"model"|!annotated:"ignoreNodeRepresentable" %}
44
// sourcery:file:Models/{{ type.localName }}/{{ type.localName }}+NodeRepresentable.generated.swift
5-
65
import Vapor
76
import Fluent
87
{% if type.annotations.import %}
@@ -14,7 +13,7 @@ import {{ var }}
1413
{% endif %}
1514

1615
extension {{ type.localName }}: NodeRepresentable {
17-
internal enum NodeKeys: String {
16+
internal enum NodeKeys {
1817
{% for var in type.storedVariables|!annotated:"ignore"|!annotated:"ignoreNodeRepresentable" %}
1918
static let {{ var.annotations.nodeKey|default:var.name }} = "{{ var.annotations.nodeKey|default:var.name }}"
2019
{% endfor %}

Models/Preparation.stencil

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
{% for type in types.based.Model|!protocol|annotated:"model"|!annotated:"ignorePreparation" %}
44
// sourcery:file:Models/{{ type.localName }}/{{ type.localName }}+Preparation.generated.swift
5-
65
import Vapor
76
import Fluent
87
{% if type.annotations.import %}
@@ -26,7 +25,7 @@ extension {{ type.localName }}: Preparation {
2625
try database.create(self) {
2726
$0.id()
2827
{% for var in type.storedVariables|!annotated:"ignore"|!annotated:"ignorePreparation" %}
29-
$0.{% if var|annotated:"preparation" %}{{ var.annotations.preparation }}{% elif var.type.based.RawStringConvertible %}enum{% else %}{{ var.typeName.description|lowercase|replace:"?","" }}{% endif %}{% if var.annotations.preparation == "foreignId" %}(for: {{ var.annotations.foreignTable }}.self, optional: {{ var.isOptional }}, unique: {{ var.annotations.unique }}, foreignIdKey: {% if var.annotations.foreignIdKey %}"{{ var.annotations.foreignIdKey }}"{% else %}DatabaseKeys.{{ var.name }}{% if var.annotations.foreignKeyName %}, foreignKeyName: "{{ var.annotations.foreignKeyName }}"{% endif %}{% endif %}){% elif var.type.based.RawStringConvertible %}(DatabaseKeys.{% if var.annotations.databaseKey %}{{ var.annotations.databaseKey }}{% else %}{{ var.name }}{% endif %}, options: {{ var.typeName }}.allRaw){% else %}(DatabaseKeys.{% if var.annotations.databaseKey %}{{ var.annotations.databaseKey }}{% else %}{{ var.name }}{% endif %}{% if var.annotations.type %}, type: "{{ var.annotations.type }}"{% endif %}{% if var.isOptional %}, optional: true{% endif %}{% if var.annotations.unique %}, unique: true{% endif %}){% endif %}
28+
$0.{% if var|annotated:"preparation" %}{{ var.annotations.preparation }}{% elif var.type.based.RawStringConvertible %}enum{% else %}{{ var.typeName.description|lowercase|replace:"?","" }}{% endif %}{% if var.annotations.preparation == "foreignId" %}(for: {{ var.annotations.foreignTable }}.self{% if var.isOptional %}, optional: true{% endif %}{% if var.annotations.unique %}, unique: {{ var.annotations.unique }}{% endif %}, foreignIdKey: {% if var.annotations.foreignIdKey %}"{{ var.annotations.foreignIdKey }}"{% else %}DatabaseKeys.{{ var.name }}{% if var.annotations.foreignKeyName %}, foreignKeyName: "{{ var.annotations.foreignKeyName }}"{% endif %}{% endif %}){% elif var.type.based.RawStringConvertible %}(DatabaseKeys.{% if var.annotations.databaseKey %}{{ var.annotations.databaseKey }}{% else %}{{ var.name }}{% endif %}, options: {{ var.typeName }}.allRaw){% else %}(DatabaseKeys.{% if var.annotations.databaseKey %}{{ var.annotations.databaseKey }}{% else %}{{ var.name }}{% endif %}{% if var.annotations.type %}, type: "{{ var.annotations.type }}"{% endif %}{% if var.isOptional %}, optional: true{% endif %}{% if var.annotations.unique %}, unique: {{ var.annotations.unique }}{% endif %}){% endif %}
3029
{% endfor %}
3130
}
3231

Models/RowConvertible.stencil

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
{% for type in types.based.Model|!protocol|annotated:"model"|!annotated:"ignoreRowConvertible" %}
44
// sourcery:file:Models/{{ type.localName }}/{{ type.localName }}+RowConvertible.generated.swift
5-
65
import Vapor
76
import Fluent
87

0 commit comments

Comments
 (0)