Comments (25)
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.
Should be fixed with the 5.3.2
. Thanks for the issue 🎉
from orval.
@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.
Can you do a pull request to fix it please?
from orval.
And if response.definition is falsy the value should be Data to have the generic type
from orval.
If you don't have time I will do it tomorrow
from orval.
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.
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.
btw,
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.
Be careful, it seems that you are not up to date with master
from orval.
But otherwise, it's a good idea
from orval.
For the relativeSafe util, it's used everywhere normally in the v5
from orval.
And please, if you do some refactoring try to do small pull request. Like that we can easily discuss it.
from orval.
Sure (about tiny commits). And indeed, version was obsolete, sorry
from orval.
@anymaniax Also, Victor, some notes, non related
-
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 asimport {rest} from 'msw';
, but to tweak output for use as configuration ofexpress
/koa
/hapi
server? You already have a parser,express
uses almost the same signature. -
Why don't you use templating? this code looks very neat.
from orval.
@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.
@Boorj can we close this one?
from orval.
@anymaniax yeah, sure. relativeSafe
with 'upath' does the job. Thank you!
from orval.
Opening again. Encountered error:
https://github.com/anymaniax/orval/blob/master/src/core/generators/api.ts#L17
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.
well, v. 6.11.0 has the same problem
from orval.
Hello @Vylda, I am currently on it. it's the same as this one #725
from orval.
Hello @Vylda, can you try if 6.11.1-alpha.1
is working for you
from orval.
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.
check here #725 did an other alpha version to fix that
from orval.
6.11.1-alpha.2 looks fine, thank you.
from orval.
Related Issues (20)
- Support for Svelte Query v5 HOT 1
- Node16 or bundler module resolution causes TS2742 error HOT 1
- Missing import of enum const in generated mock when using split mode HOT 5
- Mock TypeError custom override HOT 7
- Possibility of TS2563 error for mock generation HOT 5
- TS2300 Duplicate identifier: duplicated imports when `mock` enabled HOT 7
- Allow overriding entire handler function in generated MSW handlers, not just response object
- Invalid typescript generation for empty schema HOT 4
- msw generation does not import used models HOT 1
- Mock generation doesn't guarantee the required property mocking
- Is possible ignore the changes in the line of OpenAPI spec version ? HOT 2
- Another duplicate export edge case
- Specify mock property overrides for a specific schema HOT 2
- Support replacing types with custom ones when transforming the input HOT 5
- React Query: Regression in 6.25.0 caused by #1207 HOT 5
- Is possible ignore the changes in the line of OpenAPI spec version ?
- Orval generates wrong import paths in ESM-only package HOT 3
- Pass an additional option object in fetcher function when using custom axios instance HOT 4
- usePrefetch+useSuspenseQuery incorrectly generates prefetchSuspenseQuery calls
- bug: readonly fields missing from mutation function input types
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from orval.