Comments (9)
Then, I will solve this problem by myself. Thanks for reporting.
from nestia.
@SkyaTura Then which directory name would be better when generating DTO automatically?
Also, how to do if duplicated directory exists?
from nestia.
@samchon depending on your thoughts about how this should be solved, I would be happy to help with this one too.
My only limitation is that I don't know deeply about reflection yet. I actually just learnt what it is, with your code 🙈
from nestia.
@samchon is it possible to bring whole type declarations to the output source, instead of just import?
In projects that use nest as private modular packages, it would also be useful to create a whole new independent package for the SDK.
from nestia.
Writing whole DTO without import
statement is enough possible llike below:
- swagger.json generated by nestia
- typescript-json
However, need to distinguish which to import or re-write the whole DTO.
Have you any plan to dstinguish them? What about distinguish them by object-literal-expression?
//----
// IMPORT
//----
// WHEN DTO TYPE IS CLEARLY DEFINED
export interface IFormalDto {
id: string;
name: string;
}
//----
// WHOLE RE-WRITE
//----
// OBJECT-LITERAL-EXPRESSION
class SomeController {
someMethod(): Promise<{ id: string; name: string; }>
}
// ALIAS TYPE FOR OBJECT-LITERAL-EXPRESSION
type SomeAlias = {
id: string;
name: string;
};
from nestia.
Would be nice to have a configuration flag that allows you to switch between "always rewrite", which could be used to create a fully independant package, or "import when possible", which would work like you said.
If I didn't misunderstood, the implementation os the second option is harder because the type isn't always clear, right?
Thinking further about it, would be useful as well if, in the future, we could, optionally, pass each type to a transformer, or some kind of hooks, defined in nestia.config, that could be used to create helper functions like form validation and object generators.
May I create an issue to elaborate how could this be useful and how could be the usage, or do you think it's out of the project scope?
from nestia.
@samchon how about using Custom AST Transformers?
@ksaldana1 had a pretty similar scenario as we do, and as demonstrated here, and in an awesome blog post, which describes the development of the idea in steps.
I think this could also be useful in #141, if approved.
from nestia.
@SkyaTura I'd been busy by another open source project. I'll try this on this sunday.
However, when nestia
re-writes all DTO, have you any idea to where those new DTOs to be placed in?
Also, do you have any idea if duplicated DTO name exists?
from nestia.
Hmm... I think, ideally a SDK should have unique type definitions, and by extension, I would always try to avoid duplicates in the API as well.
But this is definitely not a well adopted as standard and should be supported by a generator.
Maybe using namespaces to replicate the original path tree, but I really need to wonder a lit bit about this question.
If we had infinite resources I would suggest multiple strategies, but unfortunitely we should also think what would be more feasable.
from nestia.
Related Issues (20)
- Nestia swagger generates incorrect schema when using EncryptedRoute with @nestjs/cache-manager HOT 2
- Question: How to improve unit / E2E test speed HOT 2
- Nestia v2 -> v3 Migration HOT 1
- Nestjs fastify use NestInterceptor auto stringify HOT 2
- Typed Route with assertEquals HOT 4
- `https://nestia.io/docs/sdk/sdk/` is broken
- Generate wrong swagger when use union type HOT 1
- Custom QueryString parser support HOT 9
- Error on MacOS but not Stackblitz -- no transform has been configured -- due to PNPM hoisting HOT 1
- Very slow reaction on NX dev + loaders error
- How to customize error message? HOT 1
- SDK generator for `@WebSocketRoute()` functions
- How to properly use nestia in Docker HOT 1
- Enhance `@nestia/sdk` performance by abandoning `ts-node` HOT 5
- is tsconfig's strictPropertyInitialization property safe to set false? HOT 3
- binded arguments in the "path" between function's decorator and parameters' decorators are different HOT 11
- Text after the comma disappears in TypedFormData.Body HOT 2
- Cannot find module 'get-funtion-location' HOT 2
- In version `3.1.4` of @nestia/core, `nestia sdk` throws a `no transform has been configured` error. HOT 2
- [Bug Report] Parsing incorrect module paths HOT 1
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 nestia.