You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
1.3KB

  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. from . import ma
  8. from marshmallow import Schema
  9. # schema for JSON transformation of User table via Marshmallow
  10. class UserSchema(ma.Schema):
  11. class Meta:
  12. fields = ('id', 'email', 'name')
  13. ordered = True
  14. # schema for JSON transformation of Resource table via Marshmallow
  15. class ToolSchema(ma.Schema):
  16. class Meta:
  17. fields = ('id', 'name', 'description', 'developer', 'developerUrl', 'projectUrl', 'repositoryUrl', 'license', 'scriptingLanguage', 'expertiseToUse', 'expertiseToHost', 'dependencies', 'ingestFormats', 'outputFormats', 'status')
  18. ordered = True
  19. class PracticeSchema(ma.Schema):
  20. class Meta:
  21. fields = ('id', 'name', 'description', 'experimental', 'lessonsLearned', 'references')
  22. ordered = True
  23. class BookSchema(ma.Schema):
  24. class Meta:
  25. fields = ('id', 'name', 'description', 'author', 'year', 'bookUrl', 'isbn')
  26. ordered = True
  27. # subschemas for nested fields
  28. class DeveloperSchema(ma.Schema):
  29. class Meta:
  30. fields = ('developer', 'developerUrl')
  31. ordered = True