Skip to content

Model

ParseResponse

Bases: BaseModel

Source code in src/parse_api/model.py
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
class ParseResponse(BaseModel):
    media_type: str | None = None
    status_code: int = 200
    content: Any = None
    headers: Mapping[str, str] | None

    def get_response(self):
        """
        Returns the FastAPI Response base on the information given by YAML file
        >>> get_response()
        Response
        """
        content = (
            json.dumps(self.content)
            if type(self.content) == dict
            else self.content
        )
        return Response(
            status_code=self.status_code,
            content=content,
            media_type=self.media_type,
            headers=self.headers,
        )

get_response()

Returns the FastAPI Response base on the information given by YAML file

get_response() Response

Source code in src/parse_api/model.py
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
def get_response(self):
    """
    Returns the FastAPI Response base on the information given by YAML file
    >>> get_response()
    Response
    """
    content = (
        json.dumps(self.content)
        if type(self.content) == dict
        else self.content
    )
    return Response(
        status_code=self.status_code,
        content=content,
        media_type=self.media_type,
        headers=self.headers,
    )