No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

schemas.py 1.4KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. # @name: schemas.py
  2. # @creation_date: 2023-01-16
  3. # @license: The MIT License <https://opensource.org/licenses/MIT>
  4. # @author: Simon Bowie <ad7588@coventry.ac.uk>
  5. # @purpose: Data schemas for API export
  6. # @acknowledgements:
  7. # https://marshmallow.readthedocs.io/en/stable/quickstart.html#next-steps
  8. # https://stackoverflow.com/questions/59721478/serializing-sqlalchemy-with-marshmallow
  9. from . import ma
  10. # schema for JSON transformation of User table via Marshmallow
  11. class UserSchema(ma.Schema):
  12. class Meta:
  13. fields = ('id', 'email', 'name')
  14. ordered = True
  15. # schema for JSON transformation of Resource table via Marshmallow
  16. class ToolSchema(ma.Schema):
  17. class Meta:
  18. fields = ('id', 'name', 'description', 'developer', 'developerUrl', 'projectUrl', 'repositoryUrl', 'license', 'scriptingLanguage', 'expertiseToUse', 'expertiseToHost', 'dependencies', 'ingestFormats', 'outputFormats', 'status')
  19. ordered = True
  20. class PracticeSchema(ma.Schema):
  21. class Meta:
  22. fields = ('id', 'name', 'description', 'experimental', 'lessonsLearned', 'references')
  23. ordered = True
  24. class BookSchema(ma.Schema):
  25. class Meta:
  26. fields = ('id', 'name', 'description', 'author', 'year', 'bookUrl', 'isbn')
  27. ordered = True
  28. # subschemas for nested fields
  29. class DeveloperSchema(ma.Schema):
  30. class Meta:
  31. fields = ('developer', 'developerUrl')
  32. ordered = True