Closed hhimanshu closed 3 years ago
Hello, sorry for your problem. With version 5, orval support multi-files when I read the other files I also try to resolve them as open API files. Which cause a problem in your case. I updated your specification to solve the problem (spec). I will think about a better solution in the future but at the moment it's the only solution sorry :(.
@anymaniax, thank you for your response. It does generate the file now. However, I have not used it yet. I am going to try now to thank you first for your work. Is it possible to make it work with fetch
instead of axios
?
Thank you @anymaniax , I will take a look
Hello @anymaniax , I tried using it again with configuration file, and now it fails with the following error. I used the same files that you added to GitHub gist earlier.
β mock-service-worker-rest git:(openapi3) β npx orval@5.2.0 --config ./orval.config.js
π» Start orval v5.2.0 - A swagger client generator for typescript
TypeError: Cannot read property 'components' of undefined
The latest code is available on the branch https://github.com/hhimanshu/rapid-front-end-development/tree/openapi3 Have I missed something?
And if I use it without 5.2.0
version, I see other errors
β mock-service-worker-rest git:(openapi3) β npx orval --config ./orval.config.js
π» Start orval v4.2.1 - A swagger client generator for typescript
Error: Every path must have a operationId - No operationId set for get /api/businesses
β mock-service-worker-rest git:(openapi3) β npx orval --config ./orval.config.js
π» Start orval v4.2.1 - A swagger client generator for typescript
Error: This library only resolve $ref that are include into `#/components/*` for now
My intention is to generate TypeScript code with react-query and msw at this time. Let me know if I have missed something. Thanks
Can you try with the 5.3.0
was a bug with the mock generation when you have multiple files specification
Hey @anymaniax , thanks for the fix. It now generates methods. I have been able to use them as well. One oddity that I found was that it did not honor the config to create a file of my choice
module.exports = {
businesses: {
output: {
mode: 'tags-split',
target: 'src/openapi/generated/interface.ts',
schemas: 'src/openapi/generated/model',
client: 'react-query',
mock: true,
},
input: {
target: './src/openapi/spec.yaml',
},
},
};
In config, I mentioned I want name of 'src/openapi/generated/interface.ts'
- reference, but it created file called default.ts
in a default
named directory - reference.
Do you know if I am missing something?
Also, how does msw
act here? Currently, my own handlers are intercepting the request, how do I make use of the ones created by orval
?
Thanks. much again!
I figured how to use fake data using msw
, however, it is not closer to my domain model so I will leave it for now. When you get a chance, please let me know how to honor the name of the output.target
file instead of using default/default.ts
. Thank you
Hello, it's because you use the mode tags-split. You maybe want the default mode 'single'? or 'split' depending on if you are using the mock.
Hello @anymaniax, I am interested in using orval and also gave it a shot. Unfortunately, it did not work even for a single time. I wonder if I am unsure about using Orval at all.
My spec is available at https://github.com/hhimanshu/rapid-front-end-development/tree/openapi3/src/openapi for the context.
I will fill the sections next
What are the steps to reproduce this issue?
I run the following command
This does not give me any indication on what went wrong, no debug logs either
What happens?
It fails it
Oups
. I also tried with a specific version, not sure if that is stable, but that doesn't works eitherWhat were you expecting to happen?
I expected for API and models to be generated for TypeScript and React-Query
Any logs, error output, etc?
I added all of what I saw above, and I hope that helps.
Any other comments?
Do you see any issues in my approach? Does Orval only work if the
$ref
is in the same file? How can I resolve this issue my friend? Thank youWhat versions are you using?
Operating System: Mac 10.15.7 Package Version:
Browser Version: N/A since I am not doing anything related to browser, yet.