Comments (9)
Hi @erik-kers,
great detailed issue with sample repo! Kudos!
Ok, abstract entities shouldn't be that hard to accomodate for. Derived entity types work as demonstrated by your example with keys, so it's more like allowing keyless entity types. I just need to find the time.
I've prepared odata2ts for open types
in the sense, that request and response may have additional properties. You won't get any exception and props are not filtered out or something. Of course, you have to take care of the typing yourself at that point by creatíng your own types based on the generated types... without metadata there's nothing odata2ts can do in this regard.
EntityType Without Keys by Virtue of Being an Open Type
However, I have problems to understand how expandos
should work without keys when they are declared as EntityType
. Hence, I think that this example is simply wrong:
<EntityType Name="OpenBaseEntity" OpenType="true" />
<EntityType Name="DynamicObject" BaseType="ExampleModel.OpenBaseEntity">
<Key>
<PropertyRef Name="Id" />
</Key>
<Property Name="Model" Type="Edm.String" />
<Property Name="Year" Type="Edm.Int32" />
</EntityType>
The main difference between EntityType
and ComplexType
is that the former requires a key while the latter does not. Only by declaring the EntityType
as abstract
you don't have to specify the key. See this explanation by Microsoft:
First, some OData terminology:
Entity type: A structured type with a key.
Complex type: A structured type without a key.
Open type: A type with dynamic properties. Both entity types and complex types can be open.
Imagine you would expose the OpenBaseEntity
as EntitySet
. You won't be able to address a specific entity by id, because the key isn't known: OpenBaseEntity(???)
. I think implementation-wise that the key must be known at compile time and cannot be used dynamically at runtime.
Additional reading: Open Types explained by odata.org
Conclusion
So this issue boils down to allowing abstract types
, right? Or do you have a specific problem with expandos
?
from odata2ts.
Hi @texttechne
I'm sorry about the late reply. I've been trying to get ahold of a real metadata-document but it doesn't seem like I will be able to do this.
You are correct in that I've made an error regarding the OpenType. I will instead give you the real example with expando.
<Schema xmlns="http://docs.oasis-open.org/odata/ns/edm" Namespace="Microsoft.Dynamics.CRM" Alias="mscrm">
<EntityType Name="crmbaseentity" Abstract="true"/>
<EntityType Name="expando" BaseType="mscrm.crmbaseentity" OpenType="true"/>
As you can see it has tyhe crmbaseentity as it's base type. And there are no other types using it as the base type. I don't know how I got that messed up tbh.
[edit: removed some irrelevant stuff]
So in summary, yes. the issue boils down to allowing types.
from odata2ts.
I'm also tried this for Microsoft Datavers. Had same issue.
Starting generation process
Found metadata file at: resource/trippin.xml
Reading metadata from file: resource/trippin.xml
Error while running the program Error: Key property is missing from Entity "crmbaseentity" (crmbaseentity)!
from odata2ts.
Related Issues (20)
- Error/Bug client.retrieveBigNumbersAsString do not exist HOT 4
- [Enhancement suggestion] Config parameter for using “Emulation of In Operator”
- [Enhancement suggestion] Reduce bundle size by only use odata V2 or V4. HOT 2
- [Enhancement suggestion] allow to add addition get parameter like sap-client HOT 8
- [Enhancement suggestion] TanStack (react-query/vue-query) compatibility HOT 1
- CSRF Token get not fetched (with fetch client) HOT 8
- auto CSRF function get confused by body HOT 5
- Post over fetch doesn't work, maybe content type wrong HOT 2
- [Enhancement suggestion] OData V2 : add the entitySet interfaces HOT 3
- For optional types, undefined is more appropriate than null using typescript. HOT 3
- Same Name in Different Namespaces Throws Error HOT 13
- [Feature Request]OData V3 Support HOT 11
- [Feature Request] generated types also for the Entity Container HOT 6
- load component issue with Odata V2 HOT 5
- [Feature Request] Deep Insert/Update support HOT 5
- [Usage Question] Addition of query parameters HOT 5
- [Bug Report] Filltering with ranges HOT 2
- [Bug Report] TypeScript: `RangeError: Maximum call stack size exceeded` HOT 9
- Very slow generation on big schema HOT 3
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 odata2ts.