Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG][Python-Fastapi] Path parameters when schema type is number causes the url to not be callable as it generates the type as strict float which can't be called by curl/browser #20315

Open
4 of 6 tasks
louissullivan4 opened this issue Dec 13, 2024 · 0 comments

Comments

@louissullivan4
Copy link
Contributor

louissullivan4 commented Dec 13, 2024

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
    Current Output:
async def order_order_id_get(
    order_id: Union[StrictFloat, StrictInt] = Path(..., description="")) -> str:

Expected Output

async def order_order_id_get(
    order_id: float = Path(..., description="")) -> str:
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

For Python Fastapi path parameter, when type is number it set it to StrictFloat which isn't good for making calls to the path parameter as when you send a url it gives you an error back as it can't convert the string value to a float. I think it would be more suitable for this value to be a float as it would allow type conversion from a curl or browser call to the server.

openapi-generator version

openapi-generator v7.10.0 and master

OpenAPI declaration file content or url
openapi: 3.0.0
info:
  title: Order API
  version: 1.0.0
paths:
  /order/{order_id}:
    parameters:
      - name: order_id
        in: path
        required: true
        schema:
          type: number
    get:
      responses:
        '200':
          description: Successfully retrieved
          content:
            application/json:
              schema:
                type: string
servers:
  - url: http://localhost:3020
Generation Details

openapi-generator generate -g python-fastapi -i in.json

Steps to reproduce
  1. Run openapi-generator generate -g python-fastapi -i in.json
  2. Open src/openapi_server/apis/default_api.py
  3. See function with path param order_id
Related issues/PRs

#20316

Suggest a fix

Set the number value to generate as float and not strict float

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant