This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from "react"; | |
import { Bar, FirstApi } from "./gen/api"; | |
function App() { | |
const [bar, setBar] = React.useState<Bar>({}) | |
React.useEffect(() => { | |
new FirstApi(undefined, "http://localhost:8000").getFoo().then((res) => { | |
setBar(res.data); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* FirstApi - object-oriented interface | |
* @export | |
* @class FirstApi | |
* @extends {BaseAPI} | |
*/ | |
export class FirstApi extends BaseAPI { | |
/** | |
* | |
* @summary Get Foo |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* | |
* @export | |
* @interface Bar | |
*/ | |
export interface Bar { | |
/** | |
* | |
* @type {Array<string>} | |
* @memberof Bar |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from fastapi import FastAPI | |
from fastapi.middleware.cors import CORSMiddleware | |
from fastapi.responses import JSONResponse | |
from pydantic import BaseModel | |
app = FastAPI() | |
app.add_middleware(CORSMiddleware, allow_origins=['*']) | |
class Bar(BaseModel): | |
items: list[str] = [] |