-
Notifications
You must be signed in to change notification settings - Fork 14
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
Incorrect swagger output for timeseries values #905
Comments
So the question here is what is the best way to correct this? Options
2 is the least breaking, 1 might arguably be the "better" solution. |
If you're unhappy with the current objects and serialization the sooner it gets fixed the better. Its only going to get harder to change it. For example: Is less verbose than: Mapping TimeSeries.Record to Object[] isn't right but if the schema was changed to Number[] it wouldn't be right either. The Record object has three fields - Long, Double, int. Forcing those into a JSON array and expecting the clients to get the types right from the schema alone isn't going to work. At least as I understand things. |
It also dawns on me that this may just be a documentation problem and people wanting automation to always be perfect. The JSON return includes a nested object that defines the columns. Seen here: https://github.com/HydrologicEngineeringCenter/cwms-data-api-client-javascript/blob/4e1c0c8066986fb55882bdddb1fd978b6021c836/cwms-swagger.json#L9296-L9301 And since we will likely optionally expand that to include the data entry date, version, and text notes, we can't directly pin down the data types. alternatively we could just have a fixed content-type for each but given the use of the simple array of arrays, that's still on the implementer end to sort out. @jbkolze @krowvin Does the above statement from me make sense. Basically "the information required is presented, just not directly on those columns" due to the nature of that data. |
Thanks for the responses. Yes, @MikeNeilson, that makes sense. It sounds like there's probably not a "quick fix" to the issue, so I imagine the path of least resistance for now is to just edit the spec in cwmsJS as needed and fall back in line with CDA if/when the spec gets worked out. I'm not worried too much about what the final answer is, but I do think it would be nice for the OpenAPI spec to be consistent with the data. I wonder if using JSON compression (e.g. gzip) for the response would allow for better data clarity (objects) while maintaining the space savings. That'd obviously be a big change to the response format, though. |
Hmm, gziping the data itself could maybe be done. Definitely a different content-type I would think. I also wonder if there's just a better way in the OpenAPI spec to define this. Sometimes it's the annotations we use in java that cause the issue vs what openapi itself can actually represented. |
There's issue with gzipping the entire HTTP request packet due to security concerns, but a field or "the data" should be doable. But that's not going to let us get more data in because the main issue is the speed of the database query, not the return back to the user once it's built. |
My understanding is you can still use As you mentioned, I also wonder if there's a more "elegant" way to handle it in the OpenAPI spec. That's unfortunately out of my bailiwick so I don't have any helpful suggestions there. Seems like something that would likely be supported in some way or another, but I suppose the question at that point will be whether the generator for cwmsJS can interpret it. |
That itself is helpful, hard to do anything but assume things work unless people speak up. And honestly that one I didn't even think about. Might be worth looking at https://github.com/HydrologicEngineeringCenter/cwms-data-api-client/tree/main/cwms-radar-model to see how it was dealt with in Java. |
If you want the types to be correct it would make more sense to have a times array and a quality array and a values array. Then each array could have its own type. |
Yeah, that's another way to do it. Given either form has performance implications when you need the other one, perhaps it makes sense to support both. @Enovotny would it be easier to map a timeseries data set to a pandas frame if it was already different arrays or more or less indifferent? |
Wrt compression - Most clients and servers transparently support gzip which is more general purpose so I didn't think too hard about it. |
the way I map it right now is a single function pd.Dataframe(json['values']) not sure it can get easier that that. I think separate arrays would make it more difficult. but it probably is just a zip call to it. If you could send me an example I could see if it works, but I would prefer that it stay as is at the moment. If you mess with that format it would likely mess with anyone outside who is grabbing data from CDA. |
We'll not worry about it for now. Were just discussing possible formats but they're all complimentary so only things that would be added, not replaced. |
I've marked this as low priority. the situation at issue has a current conclusion but there's always room for improvement. If any one comes up with new ideas or finally has a specific need please comment more here. |
Originally from HydrologicEngineeringCenter/cwms-data-api-client-javascript#3 and reported by @jbkolze
https://github.com/HydrologicEngineeringCenter/cwms-data-api-client-javascript/blob/4e1c0c8066986fb55882bdddb1fd978b6021c836/cwms-swagger.json#L9308-L9334
The "values" key in the TimeSeries return object is defined in the OpenAPI as an array of arrays of objects. The actual returned object is just an array of arrays of numbers (with no actual definition/structure). This is causing typing issues when using the cwmsjs library with TypeScript.
The text was updated successfully, but these errors were encountered: