Skip to content
Discussion options

You must be logged in to vote

Hi @Nekidev - well not out of the box for the moment - but you can use openapi_extra to pass headers schema:

@api.get(openapi_extra={"responses": {200: {"headers": ...}}})
def hello(...

here is a quick code on how to convet schema to openapi responses:

import random
from ninja import NinjaAPI, Schema, Field
from django.http import HttpRequest, HttpResponse


class NumberResponse(Schema):
    value: int


class HelloHeaders(Schema):
    x_hello: str = Field(..., alias="X-hello", description="Static greeting value returned on every call.")


api = NinjaAPI()


def _schema_to_openapi(schema):
    """Creates an OpenAPI-compatible headers block from a Ninja/Pydantic schema."""
    properties = 

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Nekidev
Comment options

Answer selected by Nekidev
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants