-
Notifications
You must be signed in to change notification settings - Fork 7
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
Schema to class hierarchy and deserialization #429
Comments
can you try using the openapi.json instead of openapi.yaml ?
…On Thu, Apr 28, 2022 at 6:34 PM yvdh ***@***.***> wrote:
Hello,
Disregard if this is not the right forum ...
I am trying to create an EPCIS repo and API from the artefacts here.
I currently have an EPCIS 1.1 environment, but I really want to move to a
JSON-REST based one as soon as possible, away from SOAP (I also feel a
clear shift in emphasis to JSON).
I want to use a very pragmatic storage model in MS SQL server: just split
up any incoming EPCIS documents in a table 'Document' with the json string
without the events in it, and a related table 'Event' with the EPCIS events
as json strings. Performance should be handled by creating the necessary
indexes on certain json paths, mainly the EPC uri's.
I work in .net - c#, and have generated an EPCIS server from the swagger
website. This resulted in a series of serializable models, but their
inheritance does not seem to reflect the JSON schema at all.
E.g. all the events (ObjectEvent, ...) inherit from a generated
'ModelEvent' (which has appropriate base properties), while the 'EventList'
property in the EPCISDocumentBody is a List of EPCISEvent which is an
mostly empty class which is not related to 'ModelEvent' in any way.
Consequenlty, any attempt at deserialization (e.g. from the sample
documents) results in mostly empty objects.
This is not much of a problem when adding EPCISDocuments during capture,
these can easily be parsed and split in a typeless manner.
It's much more of a problem when querying and assembling QueryDocuments in
the Query interface or deserializing objects client-side.
I could move away from the standard Query interfaces, and just basically
return EPCIS events for what I think will be mainly EPC uri based queries,
but even these much simpler objects do not seem to deserialize properly in
the swagger generated models ...
I feel I am doing something very wrong here, but what? At the same time
there seems to be a fundamental discrepancy between the JSON or XML schema
and the models hierarchies that are generated from them by any current
tooling ... (I have also tried NSwag and Visual Studio itself, they all
lead to different and seemingly inconsistent models).
Any help is much appreciated ...
Yves
—
Reply to this email directly, view it on GitHub
<#429>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AQEZJLRPDLHVSMPRCUUG3CLVHK42FANCNFSM5UTCRELA>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
--
*IOTA Foundation*
Pappelallee 78/79
10437 Berlin, Germany
Board of
Directors: Dominik Schiener, Navin Ramachandran
ID/Foundation No.:
3416/1234/2 (Foundation Register of Berlin)
|
Hello, I used NSwagStudio to generate models from the openAPI.json and got the same ambiguity: Events inherit from a base Event class (public partial class AggregationEvent : Event) Event base class has the correct base properties: EventTime, RecordTime, LDContext, ... But EpcisDocumentBody has a reference to EventList which derives from ... nothing! public partial class EventList : System.Collections.ObjectModel.Collection, which is even missing as a type ... So it seems NSwagStudio is missing a beat here ... I manually adjusted this to be a collection of 'Event'. |
Nswag generated models from openAPI.json or openAPI.yaml, after manually tweaking the inheritance still has problems in that the ObjectEvent is missing. I have no idea why this class in not created ... When I use the json schema with NSwag to generate only the classes the ObjectEvent is included. Tweaking to get proper inheritance is quite easy but so far deserialization is not working (empty properties). I'll keep working on that The swagger generated models (using the swagger website provided in this repository) has fundamentally incorrect inheritance (see first post) and keeps failing in deserialization, with most properties not filled in. I have not tried starting from the xsd schema's, I will give that a go too. Whatever the outcome, I think that having a clear manner in which to generate a set of classes for deserialization (and possible the API boilerplate code) in standard languages would constitute a major plus for implementers, and the current tooling does not work well enough ... Cheers |
Hello,
Disregard if this is not the right forum ...
I am trying to create an EPCIS repo and API from the artefacts here.
I currently have an EPCIS 1.1 environment, but I really want to move to a JSON-REST based one as soon as possible, away from SOAP (I also feel a clear shift in emphasis to JSON).
I want to use a very pragmatic storage model in MS SQL server: just split up any incoming EPCIS documents in a table 'Document' with the json string without the events in it, and a related table 'Event' with the EPCIS events as json strings. Performance should be handled by creating the necessary indexes on certain json paths, mainly the EPC uri's.
I work in .net - c#, and have generated an EPCIS server from the swagger website. This resulted in a series of serializable models, but their inheritance does not seem to reflect the JSON schema at all.
E.g. all the events (ObjectEvent, ...) inherit from a generated 'ModelEvent' (which has appropriate base properties), while the 'EventList' property in the EPCISDocumentBody is a List of EPCISEvent which is an mostly empty class which is not related to 'ModelEvent' in any way.
Consequenlty, any attempt at deserialization (e.g. from the sample documents) results in mostly empty objects.
This is not much of a problem when adding EPCISDocuments during capture, these can easily be parsed and split in a typeless manner.
It's much more of a problem when querying and assembling QueryDocuments in the Query interface or deserializing objects client-side.
I could move away from the standard Query interfaces, and just basically return EPCIS events for what I think will be mainly EPC uri based queries, but even these much simpler objects do not seem to deserialize properly in the swagger generated models ...
I feel I am doing something very wrong here, but what? At the same time there seems to be a fundamental discrepancy between the JSON or XML schema and the models hierarchies that are generated from them by any current tooling ... (I have also tried NSwag and Visual Studio itself, they all lead to different and seemingly inconsistent models).
Any help is much appreciated ...
Yves
The text was updated successfully, but these errors were encountered: