OData / ODataConnectedService

A Visual Studio extension for generating client code for OData Services
Other
81 stars 44 forks source link

Argument list too long: odata-cli #327

Closed ogysha closed 7 months ago

ogysha commented 1 year ago

I'm trying to generate proxy classes from a pretty big ERP OData endpoint, and the tool fails with the error: argument list too long: odata-cli

I've created a pipe of commands to exclude all types but one, and it is valid but fails due to a great amount of -est argument length.

$ odata-cli generate -m "https://.....dynamics.com/data/" -o "." -fn "ERPODataClient" -ucc -iue -est "$(cat ConnectedService.json | jq '.ExtendedData.ExcludedSchemaTypes' | sed '1d;$d' | sed 's/[ "]//g' | awk -v d="" '{s=(NR==1?s:s d)$0}END{print s}')" -ebo "$(cat ConnectedService.json | jq '.ExtendedData.ExcludedBoundOperations' | sed '1d;$d' | sed 's/[ "]//g' | sed 's/(.*//g' | sed 's/$/,/g' | awk -v d="" '{s=(NR==1?s:s d)$0}END{print s}'TypeV2)"

I want tool to be able to read input args from .json config like in Visual Studio extension which generates ConnectedService.json file from which it executes the generation of proxy classes.

If I add in the pipe head -n 100 to limit to 100 lines which I concatenate into -est and -ebo argument, then all is okay.

odata-cli generate -m "https://foo-test.sandbox.operations.dynamics.com/data/" -o "." -fn "ERPODataClient" -ucc -iue -est "$(cat ConnectedService.json | jq '.ExtendedData.ExcludedSchemaTypes' | sed '1d;$d' | sed 's/[ "]//g' | head -n 100 | awk -v d="" '{s=(NR==1?s:s d)$0}END{print s}')" -ebo "$(cat ConnectedService.json | jq '.ExtendedData.ExcludedBoundOperations' | sed '1d;$d' | sed 's/[ "]//g' | sed 's/(.*//g' | sed 's/$/,/g' | head -n 100 | awk -v d="" '{s=(NR==1?s:s d)$0}END{print s}'TypeV2)"
mtherien commented 1 year ago

+1 Creative workaround.

AndreasHassing commented 1 year ago

Would an option like: --included-schema-types work better?

It would turn the set of entities included for generation upside down, so it would be a mutually exclusive option with the exclusion list and only generate data types for the listed entries?

I feel like at least for Dynamics with some 3k+ entity sets, it makes sense to inverse the logic 😊.

ogysha commented 1 year ago

That would be a perfect solution! I would like to contribute to this one by creating a PR for it.

ElizabethOkerio commented 1 year ago

@ogysha we'll appreciate a contribution on this.

FH-Inway commented 1 year ago

:+1: to run odata-cli with a config .json file.

For trimming down huge ERP OData endpoints (and specifically Dynamics 365 FO), take a look at https://github.com/shashisadasivan/EDMXTrimmer

AndreasHassing commented 1 year ago

πŸ‘ to run odata-cli with a config .json file.

For trimming down huge ERP OData endpoints (and specifically Dynamics 365 FO), take a look at https://github.com/shashisadasivan/EDMXTrimmer

That's really cool, except that it doesn't keep relations which are very useful artifacts for certain complicated applications using the OData schema for code generation.

Edit: their code could be altered to include relations, while that increases the complexity quite a bit.

Edit 2: nevermind.. I glanced too quickly at the code and misunderstood. It does keep navigation links if the linked-to entity is also selected.

FH-Inway commented 1 year ago

@AndreasHassing Do you mean the NavigationProperty tags under the EntityType?

AndreasHassing commented 1 year ago

@AndreasHassing Do you mean the NavigationProperty tags under the EntityType?

That's right.