OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)
[ ] [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
Adding a default to an optional query parameter of type int leads to invalid arguments for Query call.
Generated code:
# coding: utf-8
from typing import Dict, List # noqa: F401
from fastapi import ( # noqa: F401
APIRouter,
Body,
Cookie,
Depends,
Form,
Header,
Path,
Query,
Response,
Security,
status,
)
from openapi_server.models.extra_models import TokenModel # noqa: F401
router = APIRouter()
@router.get(
"/pet/findByStatus",
responses={
200: {"description": "successful operation"},
},
tags=["default"],
response_model_by_alias=True,
)
async def pet_find_by_status_get(
status: str = Query('default_string', description="Status values that need to be considered for filter"),
) -> None:
"""Multiple status values can be provided with comma separated strings"""
...
openapi-generator version
Version 6.6.0
OpenAPI declaration file content or url
openapi: 3.0.2
servers:
- url: /v3
info:
description: ""
version: 1.0.17
title: Swagger Petstore - OpenAPI 3.0
paths:
/pet/findByStatus:
get:
description: Multiple status values can be provided with comma separated strings
parameters:
- in: query
name: status
description: Status values that need to be considered for filter
schema:
type: string
default: "default_string"
responses:
'200':
description: successful operation
Bug Report Checklist
Description
Adding a
default
to an optional query parameter of typeint
leads to invalid arguments forQuery
call.Generated code:
openapi-generator version
Version 6.6.0
OpenAPI declaration file content or url
Steps to reproduce
Look in
default_api.py
line 33:Related issues/PRs
None found
Suggest a fix
Change
{{default}}
in endpoint_arguments_definition.mustache, to {{&default}}.