We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Wrong Ticket Type for Free Tickets
**Describe the bug**
The ticket type of free tickets is shown as TICKET_TYPE_PAID.

**To Reproduce**
Try booking a ticket using attendee app.

**Expected behavior**
The ticket type of free tickets should be TICKET_TYPE_FREE.



--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `app/api/schema/tickets.py`
Content:
```
1 from marshmallow import validates_schema
2 from marshmallow_jsonapi import fields
3 from marshmallow_jsonapi.flask import Relationship
4 from sqlalchemy.orm.exc import NoResultFound
5 
6 from app.api.helpers.exceptions import UnprocessableEntity
7 from app.api.helpers.utilities import dasherize
8 from app.api.schema.base import SoftDeletionSchema
9 from app.models.discount_code import DiscountCode
10 from app.models.ticket import Ticket
11 from utils.common import use_defaults
12 
13 
14 @use_defaults()
15 class TicketSchemaPublic(SoftDeletionSchema):
16     class Meta:
17         type_ = 'ticket'
18         self_view = 'v1.ticket_detail'
19         self_view_kwargs = {'id': '<id>'}
20         inflect = dasherize
21 
22     @validates_schema(pass_original=True)
23     def validate_date(self, data, original_data):
24         if 'id' in original_data['data']:
25             ticket = Ticket.query.filter_by(id=original_data['data']['id']).one()
26 
27             if 'sales_starts_at' not in data:
28                 data['sales_starts_at'] = ticket.sales_starts_at
29 
30             if 'sales_ends_at' not in data:
31                 data['sales_ends_at'] = ticket.sales_ends_at
32 
33             # if 'event_ends_at' not in data:
34             #     data['event_ends_at'] = ticket.event.ends_at
35 
36         if data['sales_starts_at'] >= data['sales_ends_at']:
37             raise UnprocessableEntity({'pointer': '/data/attributes/sales-ends-at'},
38                                       "sales-ends-at should be after sales-starts-at")
39 
40         # if 'event_ends_at' in data and data['sales_starts_at'] > data['event_ends_at']:
41         #     raise UnprocessableEntity({'pointer': '/data/attributes/sales-starts-at'},
42         #                               "ticket sales-starts-at should be before event ends-at")
43 
44         # if 'event_ends_at' in data and data['sales_ends_at'] > data['event_ends_at']:
45         #     raise UnprocessableEntity({'pointer': '/data/attributes/sales-ends-at'},
46         #                               "ticket sales-ends-at should be before event ends-at")
47 
48     @validates_schema
49     def validate_quantity(self, data):
50         if 'max_order' in data and 'min_order' in data:
51             if data['max_order'] < data['min_order']:
52                 raise UnprocessableEntity({'pointer': '/data/attributes/max-order'},
53                                           "max-order should be greater than or equal to min-order")
54 
55         if 'quantity' in data and 'min_order' in data:
56             if data['quantity'] < data['min_order']:
57                 raise UnprocessableEntity({'pointer': '/data/attributes/quantity'},
58                                           "quantity should be greater than or equal to min-order")
59 
60         if 'min_price' in data and 'max_price' in data and data['type'] == 'donation':
61                 if data['min_price'] > data['max_price']:
62                     raise UnprocessableEntity({'pointer': '/data/attributes/min-price'},
63                                               "minimum price should be lesser than or equal to maximum price")
64 
65         if 'quantity' in data and 'max_order' in data:
66             if data['quantity'] < data['max_order']:
67                 raise UnprocessableEntity({'pointer': '/data/attributes/quantity'},
68                                           "quantity should be greater than or equal to max-order")
69 
70     @validates_schema(pass_original=True)
71     def validate_discount_code(self, data, original_data):
72         if 'relationships' in original_data and 'discount-codes' in original_data['data']['relationships']:
73             discount_codes = original_data['data']['relationships']['discount-codes']
74             for code in discount_codes['data']:
75                 try:
76                     DiscountCode.query.filter_by(id=code['id']).one()
77                 except NoResultFound:
78                     raise UnprocessableEntity(
79                         {'pointer': '/data/relationships/discount-codes'}, "Discount code does not exist")
80 
81     id = fields.Str(dump_only=True)
82     name = fields.Str(required=True)
83     description = fields.Str(allow_none=True)
84     type = fields.Str(required=True)
85     price = fields.Float(validate=lambda n: n >= 0, allow_none=True)
86     min_price = fields.Float(validate=lambda n: n >= 0)
87     max_price = fields.Float(validate=lambda n: n >= 0, allow_none=True)
88     quantity = fields.Integer(validate=lambda n: n >= 0, allow_none=True)
89     is_description_visible = fields.Boolean(default=False)
90     position = fields.Integer(allow_none=True)
91     is_fee_absorbed = fields.Boolean()
92     sales_starts_at = fields.DateTime(required=True)
93     sales_ends_at = fields.DateTime(required=True)
94     is_hidden = fields.Boolean(default=False)
95     min_order = fields.Integer(validate=lambda n: n >= 0, allow_none=True)
96     max_order = fields.Integer(validate=lambda n: n >= 0, allow_none=True)
97     is_checkin_restricted = fields.Boolean(default=True)
98     auto_checkin_enabled = fields.Boolean(default=False)
99     event = Relationship(attribute='event',
100                          self_view='v1.ticket_event',
101                          self_view_kwargs={'id': '<id>'},
102                          related_view='v1.event_detail',
103                          related_view_kwargs={'ticket_id': '<id>'},
104                          schema='EventSchemaPublic',
105                          type_='event')
106 
107     ticket_tags = Relationship(attribute='tags',
108                                self_view='v1.ticket_ticket_tag',
109                                self_view_kwargs={'id': '<id>'},
110                                related_view='v1.ticket_tag_list',
111                                related_view_kwargs={'ticket_id': '<id>'},
112                                schema='TicketTagSchema',
113                                many=True,
114                                type_='ticket-tag')
115 
116     discount_codes = Relationship(
117         attribute='discount_codes',
118         self_view='v1.ticket_discount_codes',
119         self_view_kwargs={'id': '<id>'},
120         related_view='v1.discount_code_list',
121         related_view_kwargs={'ticket_id': '<id>'},
122         schema='DiscountCodeSchemaTicket',
123         many=True,
124         type_='discount-code')
125 
126 
127 class TicketSchema(TicketSchemaPublic):
128     class Meta:
129         type_ = 'ticket'
130         self_view = 'v1.ticket_detail'
131         self_view_kwargs = {'id': '<id>'}
132         inflect = dasherize
133 
134     access_codes = Relationship(attribute='access_codes',
135                                 self_view='v1.ticket_access_code',
136                                 self_view_kwargs={'id': '<id>'},
137                                 related_view='v1.access_code_list',
138                                 related_view_kwargs={'ticket_id': '<id>'},
139                                 schema='AccessCodeSchema',
140                                 many=True,
141                                 type_='access-code')
142     attendees = Relationship(attribute='ticket_holders',
143                              self_view='v1.ticket_attendees',
144                              self_view_kwargs={'id': '<id>'},
145                              related_view='v1.attendee_list_post',
146                              related_view_kwargs={'ticket_id': '<id>'},
147                              schema='AttendeeSchema',
148                              many=True,
149                              type_='attendee')
150
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/app/api/schema/tickets.py b/app/api/schema/tickets.py
--- a/app/api/schema/tickets.py
+++ b/app/api/schema/tickets.py
@@ -67,6 +67,12 @@
                 raise UnprocessableEntity({'pointer': '/data/attributes/quantity'},
                                           "quantity should be greater than or equal to max-order")
 
+    @validates_schema
+    def validate_price(self, data):
+        if data['type'] == 'paid' and ('price' not in data or data['price'] <= 0):
+            raise UnprocessableEntity({'pointer': 'data/attributes/price'},
+                                      "paid ticket price should be greater than 0")
+
     @validates_schema(pass_original=True)
     def validate_discount_code(self, data, original_data):
         if 'relationships' in original_data and 'discount-codes' in original_data['data']['relationships']:

{"golden_diff": "diff --git a/app/api/schema/tickets.py b/app/api/schema/tickets.py\n--- a/app/api/schema/tickets.py\n+++ b/app/api/schema/tickets.py\n@@ -67,6 +67,12 @@\n                 raise UnprocessableEntity({'pointer': '/data/attributes/quantity'},\n                                           \"quantity should be greater than or equal to max-order\")\n \n+    @validates_schema\n+    def validate_price(self, data):\n+        if data['type'] == 'paid' and ('price' not in data or data['price'] <= 0):\n+            raise UnprocessableEntity({'pointer': 'data/attributes/price'},\n+                                      \"paid ticket price should be greater than 0\")\n+\n     @validates_schema(pass_original=True)\n     def validate_discount_code(self, data, original_data):\n         if 'relationships' in original_data and 'discount-codes' in original_data['data']['relationships']:\n", "issue": "Wrong Ticket Type for Free Tickets\n**Describe the bug**\r\nThe ticket type of free tickets is shown as TICKET_TYPE_PAID.\r\n\r\n**To Reproduce**\r\nTry booking a ticket using attendee app.\r\n\r\n**Expected behavior**\r\nThe ticket type of free tickets should be TICKET_TYPE_FREE.\r\n\r\n\n", "before_files": [{"content": "from marshmallow import validates_schema\nfrom marshmallow_jsonapi import fields\nfrom marshmallow_jsonapi.flask import Relationship\nfrom sqlalchemy.orm.exc import NoResultFound\n\nfrom app.api.helpers.exceptions import UnprocessableEntity\nfrom app.api.helpers.utilities import dasherize\nfrom app.api.schema.base import SoftDeletionSchema\nfrom app.models.discount_code import DiscountCode\nfrom app.models.ticket import Ticket\nfrom utils.common import use_defaults\n\n\n@use_defaults()\nclass TicketSchemaPublic(SoftDeletionSchema):\n    class Meta:\n        type_ = 'ticket'\n        self_view = 'v1.ticket_detail'\n        self_view_kwargs = {'id': '<id>'}\n        inflect = dasherize\n\n    @validates_schema(pass_original=True)\n    def validate_date(self, data, original_data):\n        if 'id' in original_data['data']:\n            ticket = Ticket.query.filter_by(id=original_data['data']['id']).one()\n\n            if 'sales_starts_at' not in data:\n                data['sales_starts_at'] = ticket.sales_starts_at\n\n            if 'sales_ends_at' not in data:\n                data['sales_ends_at'] = ticket.sales_ends_at\n\n            # if 'event_ends_at' not in data:\n            #     data['event_ends_at'] = ticket.event.ends_at\n\n        if data['sales_starts_at'] >= data['sales_ends_at']:\n            raise UnprocessableEntity({'pointer': '/data/attributes/sales-ends-at'},\n                                      \"sales-ends-at should be after sales-starts-at\")\n\n        # if 'event_ends_at' in data and data['sales_starts_at'] > data['event_ends_at']:\n        #     raise UnprocessableEntity({'pointer': '/data/attributes/sales-starts-at'},\n        #                               \"ticket sales-starts-at should be before event ends-at\")\n\n        # if 'event_ends_at' in data and data['sales_ends_at'] > data['event_ends_at']:\n        #     raise UnprocessableEntity({'pointer': '/data/attributes/sales-ends-at'},\n        #                               \"ticket sales-ends-at should be before event ends-at\")\n\n    @validates_schema\n    def validate_quantity(self, data):\n        if 'max_order' in data and 'min_order' in data:\n            if data['max_order'] < data['min_order']:\n                raise UnprocessableEntity({'pointer': '/data/attributes/max-order'},\n                                          \"max-order should be greater than or equal to min-order\")\n\n        if 'quantity' in data and 'min_order' in data:\n            if data['quantity'] < data['min_order']:\n                raise UnprocessableEntity({'pointer': '/data/attributes/quantity'},\n                                          \"quantity should be greater than or equal to min-order\")\n\n        if 'min_price' in data and 'max_price' in data and data['type'] == 'donation':\n                if data['min_price'] > data['max_price']:\n                    raise UnprocessableEntity({'pointer': '/data/attributes/min-price'},\n                                              \"minimum price should be lesser than or equal to maximum price\")\n\n        if 'quantity' in data and 'max_order' in data:\n            if data['quantity'] < data['max_order']:\n                raise UnprocessableEntity({'pointer': '/data/attributes/quantity'},\n                                          \"quantity should be greater than or equal to max-order\")\n\n    @validates_schema(pass_original=True)\n    def validate_discount_code(self, data, original_data):\n        if 'relationships' in original_data and 'discount-codes' in original_data['data']['relationships']:\n            discount_codes = original_data['data']['relationships']['discount-codes']\n            for code in discount_codes['data']:\n                try:\n                    DiscountCode.query.filter_by(id=code['id']).one()\n                except NoResultFound:\n                    raise UnprocessableEntity(\n                        {'pointer': '/data/relationships/discount-codes'}, \"Discount code does not exist\")\n\n    id = fields.Str(dump_only=True)\n    name = fields.Str(required=True)\n    description = fields.Str(allow_none=True)\n    type = fields.Str(required=True)\n    price = fields.Float(validate=lambda n: n >= 0, allow_none=True)\n    min_price = fields.Float(validate=lambda n: n >= 0)\n    max_price = fields.Float(validate=lambda n: n >= 0, allow_none=True)\n    quantity = fields.Integer(validate=lambda n: n >= 0, allow_none=True)\n    is_description_visible = fields.Boolean(default=False)\n    position = fields.Integer(allow_none=True)\n    is_fee_absorbed = fields.Boolean()\n    sales_starts_at = fields.DateTime(required=True)\n    sales_ends_at = fields.DateTime(required=True)\n    is_hidden = fields.Boolean(default=False)\n    min_order = fields.Integer(validate=lambda n: n >= 0, allow_none=True)\n    max_order = fields.Integer(validate=lambda n: n >= 0, allow_none=True)\n    is_checkin_restricted = fields.Boolean(default=True)\n    auto_checkin_enabled = fields.Boolean(default=False)\n    event = Relationship(attribute='event',\n                         self_view='v1.ticket_event',\n                         self_view_kwargs={'id': '<id>'},\n                         related_view='v1.event_detail',\n                         related_view_kwargs={'ticket_id': '<id>'},\n                         schema='EventSchemaPublic',\n                         type_='event')\n\n    ticket_tags = Relationship(attribute='tags',\n                               self_view='v1.ticket_ticket_tag',\n                               self_view_kwargs={'id': '<id>'},\n                               related_view='v1.ticket_tag_list',\n                               related_view_kwargs={'ticket_id': '<id>'},\n                               schema='TicketTagSchema',\n                               many=True,\n                               type_='ticket-tag')\n\n    discount_codes = Relationship(\n        attribute='discount_codes',\n        self_view='v1.ticket_discount_codes',\n        self_view_kwargs={'id': '<id>'},\n        related_view='v1.discount_code_list',\n        related_view_kwargs={'ticket_id': '<id>'},\n        schema='DiscountCodeSchemaTicket',\n        many=True,\n        type_='discount-code')\n\n\nclass TicketSchema(TicketSchemaPublic):\n    class Meta:\n        type_ = 'ticket'\n        self_view = 'v1.ticket_detail'\n        self_view_kwargs = {'id': '<id>'}\n        inflect = dasherize\n\n    access_codes = Relationship(attribute='access_codes',\n                                self_view='v1.ticket_access_code',\n                                self_view_kwargs={'id': '<id>'},\n                                related_view='v1.access_code_list',\n                                related_view_kwargs={'ticket_id': '<id>'},\n                                schema='AccessCodeSchema',\n                                many=True,\n                                type_='access-code')\n    attendees = Relationship(attribute='ticket_holders',\n                             self_view='v1.ticket_attendees',\n                             self_view_kwargs={'id': '<id>'},\n                             related_view='v1.attendee_list_post',\n                             related_view_kwargs={'ticket_id': '<id>'},\n                             schema='AttendeeSchema',\n                             many=True,\n                             type_='attendee')\n", "path": "app/api/schema/tickets.py"}], "after_files": [{"content": "from marshmallow import validates_schema\nfrom marshmallow_jsonapi import fields\nfrom marshmallow_jsonapi.flask import Relationship\nfrom sqlalchemy.orm.exc import NoResultFound\n\nfrom app.api.helpers.exceptions import UnprocessableEntity\nfrom app.api.helpers.utilities import dasherize\nfrom app.api.schema.base import SoftDeletionSchema\nfrom app.models.discount_code import DiscountCode\nfrom app.models.ticket import Ticket\nfrom utils.common import use_defaults\n\n\n@use_defaults()\nclass TicketSchemaPublic(SoftDeletionSchema):\n    class Meta:\n        type_ = 'ticket'\n        self_view = 'v1.ticket_detail'\n        self_view_kwargs = {'id': '<id>'}\n        inflect = dasherize\n\n    @validates_schema(pass_original=True)\n    def validate_date(self, data, original_data):\n        if 'id' in original_data['data']:\n            ticket = Ticket.query.filter_by(id=original_data['data']['id']).one()\n\n            if 'sales_starts_at' not in data:\n                data['sales_starts_at'] = ticket.sales_starts_at\n\n            if 'sales_ends_at' not in data:\n                data['sales_ends_at'] = ticket.sales_ends_at\n\n            # if 'event_ends_at' not in data:\n            #     data['event_ends_at'] = ticket.event.ends_at\n\n        if data['sales_starts_at'] >= data['sales_ends_at']:\n            raise UnprocessableEntity({'pointer': '/data/attributes/sales-ends-at'},\n                                      \"sales-ends-at should be after sales-starts-at\")\n\n        # if 'event_ends_at' in data and data['sales_starts_at'] > data['event_ends_at']:\n        #     raise UnprocessableEntity({'pointer': '/data/attributes/sales-starts-at'},\n        #                               \"ticket sales-starts-at should be before event ends-at\")\n\n        # if 'event_ends_at' in data and data['sales_ends_at'] > data['event_ends_at']:\n        #     raise UnprocessableEntity({'pointer': '/data/attributes/sales-ends-at'},\n        #                               \"ticket sales-ends-at should be before event ends-at\")\n\n    @validates_schema\n    def validate_quantity(self, data):\n        if 'max_order' in data and 'min_order' in data:\n            if data['max_order'] < data['min_order']:\n                raise UnprocessableEntity({'pointer': '/data/attributes/max-order'},\n                                          \"max-order should be greater than or equal to min-order\")\n\n        if 'quantity' in data and 'min_order' in data:\n            if data['quantity'] < data['min_order']:\n                raise UnprocessableEntity({'pointer': '/data/attributes/quantity'},\n                                          \"quantity should be greater than or equal to min-order\")\n\n        if 'min_price' in data and 'max_price' in data and data['type'] == 'donation':\n                if data['min_price'] > data['max_price']:\n                    raise UnprocessableEntity({'pointer': '/data/attributes/min-price'},\n                                              \"minimum price should be lesser than or equal to maximum price\")\n\n        if 'quantity' in data and 'max_order' in data:\n            if data['quantity'] < data['max_order']:\n                raise UnprocessableEntity({'pointer': '/data/attributes/quantity'},\n                                          \"quantity should be greater than or equal to max-order\")\n\n    @validates_schema\n    def validate_price(self, data):\n        if data['type'] == 'paid' and ('price' not in data or data['price'] <= 0):\n            raise UnprocessableEntity({'pointer': 'data/attributes/price'},\n                                      \"paid ticket price should be greater than 0\")\n\n    @validates_schema(pass_original=True)\n    def validate_discount_code(self, data, original_data):\n        if 'relationships' in original_data and 'discount-codes' in original_data['data']['relationships']:\n            discount_codes = original_data['data']['relationships']['discount-codes']\n            for code in discount_codes['data']:\n                try:\n                    DiscountCode.query.filter_by(id=code['id']).one()\n                except NoResultFound:\n                    raise UnprocessableEntity(\n                        {'pointer': '/data/relationships/discount-codes'}, \"Discount code does not exist\")\n\n    id = fields.Str(dump_only=True)\n    name = fields.Str(required=True)\n    description = fields.Str(allow_none=True)\n    type = fields.Str(required=True)\n    price = fields.Float(validate=lambda n: n >= 0, allow_none=True)\n    min_price = fields.Float(validate=lambda n: n >= 0)\n    max_price = fields.Float(validate=lambda n: n >= 0, allow_none=True)\n    quantity = fields.Integer(validate=lambda n: n >= 0, allow_none=True)\n    is_description_visible = fields.Boolean(default=False)\n    position = fields.Integer(allow_none=True)\n    is_fee_absorbed = fields.Boolean()\n    sales_starts_at = fields.DateTime(required=True)\n    sales_ends_at = fields.DateTime(required=True)\n    is_hidden = fields.Boolean(default=False)\n    min_order = fields.Integer(validate=lambda n: n >= 0, allow_none=True)\n    max_order = fields.Integer(validate=lambda n: n >= 0, allow_none=True)\n    is_checkin_restricted = fields.Boolean(default=True)\n    auto_checkin_enabled = fields.Boolean(default=False)\n    event = Relationship(attribute='event',\n                         self_view='v1.ticket_event',\n                         self_view_kwargs={'id': '<id>'},\n                         related_view='v1.event_detail',\n                         related_view_kwargs={'ticket_id': '<id>'},\n                         schema='EventSchemaPublic',\n                         type_='event')\n\n    ticket_tags = Relationship(attribute='tags',\n                               self_view='v1.ticket_ticket_tag',\n                               self_view_kwargs={'id': '<id>'},\n                               related_view='v1.ticket_tag_list',\n                               related_view_kwargs={'ticket_id': '<id>'},\n                               schema='TicketTagSchema',\n                               many=True,\n                               type_='ticket-tag')\n\n    discount_codes = Relationship(\n        attribute='discount_codes',\n        self_view='v1.ticket_discount_codes',\n        self_view_kwargs={'id': '<id>'},\n        related_view='v1.discount_code_list',\n        related_view_kwargs={'ticket_id': '<id>'},\n        schema='DiscountCodeSchemaTicket',\n        many=True,\n        type_='discount-code')\n\n\nclass TicketSchema(TicketSchemaPublic):\n    class Meta:\n        type_ = 'ticket'\n        self_view = 'v1.ticket_detail'\n        self_view_kwargs = {'id': '<id>'}\n        inflect = dasherize\n\n    access_codes = Relationship(attribute='access_codes',\n                                self_view='v1.ticket_access_code',\n                                self_view_kwargs={'id': '<id>'},\n                                related_view='v1.access_code_list',\n                                related_view_kwargs={'ticket_id': '<id>'},\n                                schema='AccessCodeSchema',\n                                many=True,\n                                type_='access-code')\n    attendees = Relationship(attribute='ticket_holders',\n                             self_view='v1.ticket_attendees',\n                             self_view_kwargs={'id': '<id>'},\n                             related_view='v1.attendee_list_post',\n                             related_view_kwargs={'ticket_id': '<id>'},\n                             schema='AttendeeSchema',\n                             many=True,\n                             type_='attendee')\n", "path": "app/api/schema/tickets.py"}]}