lca_carbon_api/schemas.py
2024-10-10 11:48:53 -04:00

38 lines
1.2 KiB
Python

"""
schemas module
Defines the schemas to post on app.py
SPDX - License - Identifier: LGPL - 3.0 - or -later
Copyright © 2024 Concordia CERC group
Code contributors: Alireza Adli alireza.adli@mail.concordia.ca
"""
from marshmallow import Schema, fields
class GeometrySchema(Schema):
"""Schema for the geometry of a feature."""
type = fields.String(required=True)
coordinates = fields.List(fields.List(fields.List(fields.Float())), required=True)
class PropertiesSchema(Schema):
"""Schema for the properties of a feature."""
name = fields.String(required=True)
address = fields.String(required=True)
function = fields.String(required=True)
height = fields.Integer(required=True)
year_of_construction = fields.Integer(required=True)
class FeatureSchema(Schema):
"""Schema for a GeoJSON feature."""
type = fields.String(required=True)
geometry = fields.Nested(GeometrySchema, required=True)
id = fields.Integer(required=True)
properties = fields.Nested(PropertiesSchema, required=True)
class LCAInputData(Schema):
"""Define variables that come from user input."""
type = fields.String(required=True)
features = fields.List(fields.Nested(FeatureSchema), required=True)