jason810496 commented on code in PR #53597: URL: https://github.com/apache/airflow/pull/53597#discussion_r2231442514
########## airflow-core/src/airflow/api_fastapi/auth/managers/simple/utils.py: ########## @@ -0,0 +1,44 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +from __future__ import annotations + +from fastapi import HTTPException, Request, status +from fastapi.exceptions import RequestValidationError +from pydantic import ValidationError + +from airflow.api_fastapi.auth.managers.simple.datamodels.login import LoginBody + + +async def parse_login_body(request: Request) -> LoginBody: Review Comment: It would be better to specify the allowed MIME type in the `Header` rather than using a vague `Request`. Using `Request` directly in the FastAPI dependencies chain will cause the OpenAPI features to be lost. Somehow like: https://github.com/apache/airflow/blob/70ff46b57991843760560a6258bbccc6bdca53d5/airflow-core/src/airflow/api_fastapi/common/headers.py#L26-L27 and add new Enum as well. ########## airflow-core/src/airflow/api_fastapi/auth/managers/simple/ui/openapi-gen/queries/queries.ts: ########## @@ -6,11 +6,7 @@ import { LoginBody } from "../requests/types.gen"; import * as Common from "./common"; export const useSimpleAuthManagerLoginServiceCreateTokenAllAdmins = <TData = Common.SimpleAuthManagerLoginServiceCreateTokenAllAdminsDefaultResponse, TError = unknown, TQueryKey extends Array<unknown> = unknown[]>(queryKey?: TQueryKey, options?: Omit<UseQueryOptions<TData, TError>, "queryKey" | "queryFn">) => useQuery<TData, TError>({ queryKey: Common.UseSimpleAuthManagerLoginServiceCreateTokenAllAdminsKeyFn(queryKey), queryFn: () => SimpleAuthManagerLoginService.createTokenAllAdmins() as TData, ...options }); export const useSimpleAuthManagerLoginServiceLoginAllAdmins = <TData = Common.SimpleAuthManagerLoginServiceLoginAllAdminsDefaultResponse, TError = unknown, TQueryKey extends Array<unknown> = unknown[]>(queryKey?: TQueryKey, options?: Omit<UseQueryOptions<TData, TError>, "queryKey" | "queryFn">) => useQuery<TData, TError>({ queryKey: Common.UseSimpleAuthManagerLoginServiceLoginAllAdminsKeyFn(queryKey), queryFn: () => SimpleAuthManagerLoginService.loginAllAdmins() as TData, ...options }); -export const useSimpleAuthManagerLoginServiceCreateToken = <TData = Common.SimpleAuthManagerLoginServiceCreateTokenMutationResult, TError = unknown, TContext = unknown>(options?: Omit<UseMutationOptions<TData, TError, { - requestBody: LoginBody; -}, TContext>, "mutationFn">) => useMutation<TData, TError, { - requestBody: LoginBody; -}, TContext>({ mutationFn: ({ requestBody }) => SimpleAuthManagerLoginService.createToken({ requestBody }) as unknown as Promise<TData>, ...options }); +export const useSimpleAuthManagerLoginServiceCreateToken = <TData = Common.SimpleAuthManagerLoginServiceCreateTokenMutationResult, TError = unknown, TContext = unknown>(options?: Omit<UseMutationOptions<TData, TError, void, TContext>, "mutationFn">) => useMutation<TData, TError, void, TContext>({ mutationFn: () => SimpleAuthManagerLoginService.createToken() as unknown as Promise<TData>, ...options }); Review Comment: IMO, we should ensure that the parameter type annotation is OpenAPI schema-aware. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
