Ejemplo n.º 1
0
    def _add_endpoint_default_response(self, schema: typing.Dict):
        dict_safe_add(schema, self.schemas[APIError], "responses", "default",
                      "content", "application/json", "schema")

        # Default description
        schema["responses"]["default"]["description"] = schema["responses"][
            "default"].get("description", "Unexpected error.")
Ejemplo n.º 2
0
    def _add_endpoint_response(self, endpoint: EndpointInfo, schema: typing.Dict):
        response_codes = list(schema.get("responses", {}).keys())
        main_response = response_codes[0] if response_codes else 200

        dict_safe_add(
            schema,
            self.schemas[endpoint.output_field],
            "responses",
            main_response,
            "content",
            "application/json",
            "schema",
        )
Ejemplo n.º 3
0
    def _add_endpoint_body(self, endpoint: EndpointInfo, schema: typing.Dict):
        component_schema = (endpoint.body_field.schema
                            if inspect.isclass(endpoint.body_field.schema) else
                            endpoint.body_field.schema.__class__)

        self.spec.definition(name=component_schema.__name__,
                             schema=component_schema)

        dict_safe_add(
            schema,
            self.openapi.schema2jsonschema(endpoint.body_field.schema),
            "requestBody",
            "content",
            "application/json",
            "schema",
        )
Ejemplo n.º 4
0
 def _add_endpoint_body(self, endpoint: EndpointInfo, schema: typing.Dict):
     dict_safe_add(schema, self.schemas[endpoint.body_field.schema],
                   "requestBody", "content", "application/json", "schema")