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

$ref parameter prevents code generation #269

Open
aktentasche opened this issue Aug 11, 2022 · 1 comment
Open

$ref parameter prevents code generation #269

aktentasche opened this issue Aug 11, 2022 · 1 comment

Comments

@aktentasche
Copy link

I am trying to use $ref parameters in my openapi yaml, however as soon as I insert a $ref entry no code is generated (the folder is but it contains no files) and no error is thrown.

I took the code from #24, so my minimum working example is:

openapi.yaml

openapi: "3.0.0"
paths:
  /foo:
    parameters:
      - $ref: "#/components/parameters/MyParam"
components:
  parameters:
    MyParam:
      name: foo
      schema:
        type: string

But the same happens with my actual openapi definition. As soon as I add a $ref parameter, no code is generated.

command:

fastapi-codegen -i openapi.yaml -o app

I am using fastapi-code-generator version 0.3.5

Can someone help? Thanks!

@aktentasche
Copy link
Author

Ok so I found out I can use $refs in the schema but this not so clean if I really want to use the exact same parameter in several places, I would need to repeat it in every place.

So in below API definition the demo_pizza_factory_instance is part of every query.

 - name: demo_pizza_factory_instance
          in: query
          description: The service instance to address this request to.
          required: true
          schema:
            $ref: "#/components/schemas/DemoPizzaFactoryInstance" 
components:
  schemas:
    DemoPizzaFactoryInstance:
      type: string
      enum:
        - hawaii 
        - funghi   

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

No branches or pull requests

1 participant