Code Monkey home page Code Monkey logo

Comments (11)

anymaniax avatar anymaniax commented on May 14, 2024

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 :(.

from orval.

hhimanshu avatar hhimanshu commented on May 14, 2024

@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?

from orval.

anymaniax avatar anymaniax commented on May 14, 2024

Hello, sure. You can use a mutator checkout the doc here and example

from orval.

hhimanshu avatar hhimanshu commented on May 14, 2024

Thank you @anymaniax , I will take a look

from orval.

hhimanshu avatar hhimanshu commented on May 14, 2024

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 [email protected] --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?

from orval.

hhimanshu avatar hhimanshu commented on May 14, 2024

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

from orval.

anymaniax avatar anymaniax commented on May 14, 2024

Can you try with the 5.3.0 was a bug with the mock generation when you have multiple files specification

from orval.

hhimanshu avatar hhimanshu commented on May 14, 2024

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!

from orval.

hhimanshu avatar hhimanshu commented on May 14, 2024

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

from orval.

anymaniax avatar anymaniax commented on May 14, 2024

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.

from orval.

hhimanshu avatar hhimanshu commented on May 14, 2024

Thank you @anymaniax, with mode: single, I was able to generate a single file. reference

from orval.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.