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

appending codesamples #506

Closed
haviduck opened this issue Aug 19, 2021 · 2 comments
Closed

appending codesamples #506

haviduck opened this issue Aug 19, 2021 · 2 comments

Comments

@haviduck
Copy link

haviduck commented Aug 19, 2021

Is your feature request related to a problem? Please describe.
No

Describe the solution you'd like
a way to execute and append the output from a snippet generator and append it to the models.

Describe alternatives you've considered
Currently i'm running this on my schema to get x-codeSamples: https://github.com/cdwv/oas3-api-snippet-enricher.
Im running a custom redoc in fastapi where openapi_url is changed to match a custom json. upon opening redocs url i grab the openapi schema,, run a os exec to enrich it and write it to a file redoc uses. it woeks, but not very efficient. i should peobably posted in your fastapi repo, but as im using this eepo (i rely on params it doesnt seem ro have)

Additional context
just wanted to thank you for sharing your work. it saves me days.

@koxudaxi
Copy link
Owner

@haviduck
Thank you for sharing the link.
It's very interesting.

But, the project is written in JS. It's difficult to call the module directly from the codegen.
You can use a pipe to append the code example.

./node_modules/.bin/snippet-enricher-cli --input=openapi.json  | datamodel-codegen --input-file-type openapi > output.py

Is my idea what you want?

@haviduck
Copy link
Author

hey thanks for replying. thats what i did when i wrote this which i did before doing enough research :) . i found a way to automate it and happy with it.
for those interested, heres the approach for fastapi enriched docs
ErikWittern/openapi-snippet#40 (comment)

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

2 participants