-
Notifications
You must be signed in to change notification settings - Fork 952
Open
Description
import os
from typing import Dict, Any
from fastapi import FastAPI
from pydantic import BaseModel
from x402.fastapi.middleware import require_payment
from x402.types import PaywallConfig, HTTPInputSchema
from cdp.x402 import create_facilitator_config
app = FastAPI(title="x402 Echo")
echo_input_schema = HTTPInputSchema(
body_type="json",
body_fields={"idx": {"type": "integer", "description": "Index to echo", "required": True}},
)
app.middleware("http")(
require_payment(
path="/echo",
price="$0.001",
pay_to_address="0xB5d6801bC3dd17648e66aE22B80757692b1C5a42",
network="base",
paywall_config=PaywallConfig(app_name="x402 Echo"),
description="Paid echo endpoint for unit tests",
mime_type="application/json",
discoverable=True,
input_schema=echo_input_schema
)
)
class EchoRequest(BaseModel):
idx: int
@app.post("/echo")
async def echo(req: EchoRequest) -> Dict[str, Any]:
return {"idx": req.idx}
For the above code hosted at https://x4023.987659876.xyz/echo when I try to preview it on x402scan.com
It doesn't resolve properly, if I remove the input schema, then the resource is listed but then how can I have the required input listed on x402scan?
Metadata
Metadata
Assignees
Labels
No labels