Code Monkey home page Code Monkey logo

Comments (25)

Boorj avatar Boorj commented on May 14, 2024

Btw, the same issue with slashes happens in project with relative paths in several places.
For example here: https://github.com/anymaniax/orval/blob/master/src/core/generators/mutator.ts#L13

from orval.

anymaniax avatar anymaniax commented on May 14, 2024

Should be fixed with the 5.3.2. Thanks for the issue 🎉

from orval.

Boorj avatar Boorj commented on May 14, 2024

@anymaniax
btw, i will not create additional issue, but this line produces incorrect code if definition is undefined

https://github.com/anymaniax/orval/blob/master/src/core/generators/react-query.ts#L82

// fails
<Data extends unknown ? ${  response.definition  } : Data>

// better
const typing = response.definition 
    ? "<Data extends unknown ? " + response.definition + " : Data>" 
    : '';

from orval.

anymaniax avatar anymaniax commented on May 14, 2024

Can you do a pull request to fix it please?

from orval.

anymaniax avatar anymaniax commented on May 14, 2024

And if response.definition is falsy the value should be Data to have the generic type

from orval.

anymaniax avatar anymaniax commented on May 14, 2024

If you don't have time I will do it tomorrow

from orval.

Boorj avatar Boorj commented on May 14, 2024

Sure, PR is on the run) Sorry, timezones lag )
Probably in next versions you can make some functions to do those name extractions consistently.

from orval.

Boorj avatar Boorj commented on May 14, 2024

Done. Also i feel like project heavily needs some refactoring to keep DRY-principle and consistency.
There's an utility here : https://github.com/anymaniax/orval/blob/master/src/utils/path.ts#L10 which provides safe relative path. I think that could be used consistently in all places. Also, all imports should be unified to correct slash, and it's missing in code, as i see (haven't check, how dependent utilities from import work).

from orval.

Boorj avatar Boorj commented on May 14, 2024

btw,
image
i'm re-writing some code at my side.

Looks like optional type of input and output brought tons of redundant code (typechecks, etc).
Isn't it easier to normalize type on start?

from orval.

anymaniax avatar anymaniax commented on May 14, 2024

Be careful, it seems that you are not up to date with master

from orval.

anymaniax avatar anymaniax commented on May 14, 2024

But otherwise, it's a good idea

from orval.

anymaniax avatar anymaniax commented on May 14, 2024

For the relativeSafe util, it's used everywhere normally in the v5

from orval.

anymaniax avatar anymaniax commented on May 14, 2024

And please, if you do some refactoring try to do small pull request. Like that we can easily discuss it.

from orval.

Boorj avatar Boorj commented on May 14, 2024

Sure (about tiny commits). And indeed, version was obsolete, sorry

from orval.

Boorj avatar Boorj commented on May 14, 2024

@anymaniax Also, Victor, some notes, non related

  1. Library generates msw mocks based on faker, and then you can use them in browser as service worker with interceptor. Also node js could use the same interceptor. Actually, i haven't seen libraries for nodejs+openapi that provide customizable responses. Only based on type. Orval has at least regexp generator for customization. And, actually, that could be quite enough.
    How do you find next idea: generate mocks not as import {rest} from 'msw';, but to tweak output for use as configuration of express/koa/hapi server? You already have a parser, express uses almost the same signature.

  2. Why don't you use templating? this code looks very neat.

from orval.

anymaniax avatar anymaniax commented on May 14, 2024

@Boorj I already thought about it and it could be a really good feature. Maybe open a new issue first this one.

For point 2 at the beginning, this project was inspired by restful-react and he wasn't using templates. I also already thought about it but it's a big refactor. I maintain this in my free time and don't have a lot of time for this one. I always thought that there were more important changes to do than that one.

from orval.

anymaniax avatar anymaniax commented on May 14, 2024

@Boorj can we close this one?

from orval.

Boorj avatar Boorj commented on May 14, 2024

@anymaniax yeah, sure. relativeSafe with 'upath' does the job. Thank you!

from orval.

Boorj avatar Boorj commented on May 14, 2024

Opening again. Encountered error:
https://github.com/anymaniax/orval/blob/master/src/core/generators/api.ts#L17

image

Getting specKey with forward slashes, and specs object has key with filename, containing backslashes.

like

specKey === 'c:/path/foo.json'
specs === { 'c:\path\foo.json\': ...}

from orval.

Vylda avatar Vylda commented on May 14, 2024

well, v. 6.11.0 has the same problem

from orval.

anymaniax avatar anymaniax commented on May 14, 2024

Hello @Vylda, I am currently on it. it's the same as this one #725

from orval.

anymaniax avatar anymaniax commented on May 14, 2024

Hello @Vylda, can you try if 6.11.1-alpha.1 is working for you

from orval.

Vylda avatar Vylda commented on May 14, 2024

Hello @anymaniax ,
I cant run orval correctly:
`npx orval --config orval.config.ts

🍻 Start orval v6.11.1-alpha.1 - A swagger client generator for typescript
node:internal/process/promises:279
triggerUncaughtException(err, true /* fromPromise */);
^

[UnhandledPromiseRejection: This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason "failed to load from C:/www/studentagency/orval.config.ts => TypeError: n is not a function".] {
code: 'ERR_UNHANDLED_REJECTION'
}`

from orval.

anymaniax avatar anymaniax commented on May 14, 2024

check here #725 did an other alpha version to fix that

from orval.

Vylda avatar Vylda commented on May 14, 2024

6.11.1-alpha.2 looks fine, thank you.

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.