-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Consider code generation from OData metadata #5
Comments
This will gen classes (could easily be extended): I'm wondering whether requiring additional framework(s) for this translation is overkill. Nowadays if something doesn't pass the "can I whip up a prototype in 5 minutes on stackblitz test" I start getting skeptical of the approach. Having said that obviously I realize the benefits of a more declarative approach. |
Looks great. |
Also, with your Decorator suggestion in use, we wouldn't need Service generation (I always thought they would be necessary). @jinquEndpoint('companies')
export class Company {
}
const service = new ODataService(url);
const companies = await service.createQuery(Company).toArrayAsync(); looks great and feels right. Btw, I completed |
I created a very simple code generator and considering to publish it alongside npm as a |
I'm not actually familiar with best strategies for distributing code generators on npm, and how to those would potentially be wired automatically into the build process. Some very rough thoughts anyway... In terms of a user of such a process, if my schema was fairly stable I'd probably prefer a one-off web tool w/ a UI to tweak the generator output, as I can avoid the steps/headache of installing, configuring, learning, running the tool. OTOH, if I was simultaneously developing a schema while developing the client, automatically re-generating the client classes could potentially be a time-saver. OTOH again, we don't have partial classes in javascript, so if I've customized those classes in any way, we're dealing with a one-time generation step. Also, part of the benefit of generation is that it teaches you how to build the types. Once you know how, it's easy to add a new field etc. |
Yeah, these were exact same scenarios in my mind. By the way, to avoid unnecessary version updates to jinqu-odata, I decided to create a new npm for metadata generation, likely named 'jinqu-odata-metadata' or something like that. |
Not really. The main benefit is that you can regenerate in the build process or as separate EASY step. If multiple teams actively develop an API, then there are times it is really tricky to keep all clients in sync. DTO - and odata classes are pure data transfer objects - should not really require customization. The benfit outweights the possible costs. |
Hi NetTecture, Agree it's nice as a build step! Umut - something that occurred to me regarding not having partial classes in Typescript... Assuming in a particular scenario you can't or don't want to use inheritance, then mixins can be used to customize the generated classes. So you |
There is also more to it than just entities. What about actions and functions? We use both extensively. I would love a decent typescript based odata client - all around seem to be VERY partial solutions. |
Well Umut (who's the project owner) can give you more info, but the work so far on jinqu has involved a lot of foundational stuff. One thing I appreciate about what jinqu is striving for, is to provide a consistent experience for LINQ queries across multiple providers, where odata is one of several possible providers. It's quite an undertaking, and you're right that there's more work ahead, but the approach looks pretty solid to me. Umut has been really responsive to feedback I've given so far - if you can spare a little time it would probably be really helpful if you can actually poke as many holes in the solution so far as possible, to help define the road map. |
Hi @NetTecture, first of all, thanks for the feedbacks. I pushed a new repo (jinqu-odata-cli), still experimenting with the idea. With this -dev dependency- approach we can use it in the build process. Also, I'm trying out generation options, for now we have "generate interfaces instead of classes", "use decorators" etc. We can always add a new option for service type generation and with this enabled, we can create a class with actions and functions. In fact, this was the approach I took for my company's one of internal framework(ish) project. Having concrete service types for REST API's make life really easier for developers. Later on, we switched to Swagger (it was for the best, I didn't like to use reflection on REST Controllers). I'm still updating my old OData knowledge with v4, now reading this. I'm sure we can implement them somehow. @solenya-group, thanks for your support and kind words. Mixins would fill the gaps, I've used them for global injections, I'm sure there wil be lots of useful scenarios for jinqu. I always missed a real LINQ counterpart for TypeScript (and JavaScript), I am trying my best to keep all API LINQ way. Last few weeks I was a little busy, hope this will change soon, there's still a lot to do. |
@umutozel
We now need to nail down which client to use in the generator and there the mess starts. I like jinqu, but it is extremely limited. Particualrly missing for us are:
Given taht whatever we go with needs to replace existing messy solutions NOW... you get the idea. I think optionally I would love to get away from all the generic style of odata and go towards an entity framework style - i.e. pull in ONE service and then ahve all the functions available on the right endpoints, possibly via some helpers. OData itself is very dynamic, but one endpoint in a specific time is not normally - the functions etc. are all predefined and in the metadata. And that is just baseline. There are a lot of more detailed internals - as much as I love linq style queries, the functional limitations are right now a breaker because we use actions and functions extensively. |
@NetTecture I think we can support inherited entities and actions/functions too. We already support Post, Patch etc (via request options). But contained entities, that's tricky. But I believe we can handle it in generated code. I contributed to swagger code generator for linquest, they have some similar solution. We can use To be honest, I would love to contribute a project like yours, maybe develop a jinqu implementation over a fork. I share your frustration and I started with a goal in mind, to solve this mess once and for all as best as I can. Yeah, this sentence always reminds me a Randall Munroe cartoon on xkcd. |
You name it. Ok, lets straight.
POST to /Event({guidgoeshere})/Response Now, always a good reference: Simple.Odata.Client: something along the line .For()
|
Code generation from OData Metadata would be great.
OpenAPI/Swagger could be next step.
The text was updated successfully, but these errors were encountered: