Questions tagged [marshmallow]

Marshmallow is an ORM/ODM/framework-agnostic library for converting complex datatypes, such as objects, to and from native Python datatypes. (For Questions about Android Marshmallow use the tag [android-6.0-marshmallow].)

Marshmallow is an ORM/ODM/framework-agnostic library for converting complex datatypes, such as objects, to and from native Python datatypes. See https://marshmallow.readthedocs.io/en/latest/index.html

589 questions
0
votes
1 answer

Displaying a description of a marshmallow Schema in OPTIONS method

I'm trying to implement a route in my flask application to serve the OPTIONS method of a given resource and return a description of the marshmallow schema associated to said resource. Something similar to what django does: { "name": "Dataset…
ldavid
  • 2,512
  • 2
  • 22
  • 38
0
votes
1 answer

Inner class as nested schema in Marshmallow?

Is it possible to use an inner class as a nested schema in Marshmallow (https://marshmallow.readthedocs.io/en/latest/)? I am trying to represent a hierarchical schema in Marshmallow which appears to be done through nested schemas. For example, I…
user783836
  • 3,099
  • 2
  • 29
  • 34
0
votes
2 answers

Is it possible to use a Postgres Interval data type with Marshmallow schema serialization?

SqlAlchemy supports Interval data types like this: class Sample(Base): __tablename__ = "samples" id = Column(Integer(), primary_key=True) time_interval = Column(Interval(), nullable=True) Is it possible to serialize an interval column…
Ender2050
  • 6,912
  • 12
  • 51
  • 55
0
votes
0 answers

How do I make a nested json schema in Marshmallow?

I am trying to take data from a table in SQL Server and convert it to a JSON format. I achieved conversion to a rudimentary JSON format using Marshmallow. I have not worked with JSON extensively. The requirement is to convert it into a hierarchical…
kaushik3993
  • 105
  • 1
  • 3
  • 10
0
votes
1 answer

is not JSON serializable
i'm creating an API in python + Flask + marshmallow. Here's the class + the first function (i don't already use the others ) import datetime from marshmallow import Schema, fields, ValidationError, pre_load from flask import Flask, jsonify from…
JeanSec
  • 11
  • 1
  • 6
0
votes
1 answer

Marshmallow allow retaining none for a value, but not clearing the value

I want to softly enforce users in a user base to set a value that previously was not required, but now is. This is the setup Users fetched from the database are validated against the database bound marshmallow schema, this allows the None…
firelynx
  • 30,616
  • 9
  • 91
  • 101
0
votes
1 answer

flask-marshmallow two db objects in one schema

I'm trying to serialize this object, which is a result of a join between two tables: query_response = [(, ), (, )] and I'm using this schema: class CompanyCompleteSchema(Schema): company =…
disgra
  • 683
  • 3
  • 6
  • 18
0
votes
1 answer

JSON data to custom object structure in Python

Disclaimer: i am a newbie in object oriented Python. My end goal is to extract data from many JSON files one at a time that have the same structure and to calculate something new from the data and to store all this in a MySQL database. How do i…
0
votes
1 answer

Adding external data to to SQLAlchemy object collection

I am building Flask based API app with flask-sqlalchemy and Postgres DB. users table in DB holds a record for each user. PK for this table is username (nothing special here) performance table in DB holds user performance. PK for this table is a…
Meir Tseitlin
  • 1,878
  • 2
  • 17
  • 28
0
votes
1 answer

Python Marshmallow - Customize formatting of class member

I have Marshmallow serializer written as class TestSchema(Schema): created_date = fields.Str(required=False) class Test(database.Model): created_date = database.Column(database.DateTime, …
Ganesh Satpute
  • 3,664
  • 6
  • 41
  • 78
0
votes
0 answers

Prevailing pattern for client side HTML tables from REST

I've built a REST API using flask and marshmallow. Now I'm wanting to show data in a table on the client side (I'm using vuejs). The JSON from the API contains related objects like so: json { match: 1, date: 2017-12-12, player: { name: "Juan",…
gotchula
  • 171
  • 1
  • 4
0
votes
2 answers

marshmallow `validates_schema` to reject unknown fields with `pass_many=True`

I struggle to understand how to handle unknown fields when the Schema is passed a list of objects for validation. I got so far : class MySchema(Schema): # fields ... @marshmallow_decorators.validates_schema(pass_original=True) def…
sebpiq
  • 7,540
  • 9
  • 52
  • 69
0
votes
1 answer

marshmallow: convert dict to tuple

Given that the input data x are: {'comm_name': 'XXX', 'comm_value': '1234:5678', 'dev_name': 'router-1'} The marshmallow schema is as follows: class BGPcommunitiesPostgresqlSchema(marshmallow.Schema): comm_name =…
nskalis
  • 2,232
  • 8
  • 30
  • 49
0
votes
2 answers

convert object when serializing it

Given that : class BGPcommunitiesElasticSchema(marshmallow.Schema): comm_name = marshmallow.fields.Str(required=True) comm_value = marshmallow.fields.Str(required=True, ) dev_name = marshmallow.fields.Str(required=True) time_stamp =…
nskalis
  • 2,232
  • 8
  • 30
  • 49
0
votes
1 answer

Work with relationships in python flask

I am completely junior programming in python, and I want to see if anyone can guide me with this problem I have encountered. I'm trying to make a REST API for a store, and I'm stuck with relationships. The problem I have is that I have the following…
user3693057