Skip to content

Add command-line option for ConnectedService.json file#363

Merged
gathogojr merged 42 commits intoOData:masterfrom
gregwinterstein:fix/338-odata-cli-ConnectedService.json
Apr 3, 2024
Merged

Add command-line option for ConnectedService.json file#363
gathogojr merged 42 commits intoOData:masterfrom
gregwinterstein:fix/338-odata-cli-ConnectedService.json

Conversation

@gregwinterstein
Copy link
Copy Markdown
Contributor

@gregwinterstein gregwinterstein commented Jun 13, 2023

Add command-line option for reading generation configuration from ConnectedService.json file
Command-line option: --connected-service-file <connected_service_file_name> or -c <connected_service_file_name>

Fixes #338
Fixes #327

@gregwinterstein gregwinterstein force-pushed the fix/338-odata-cli-ConnectedService.json branch from cca12e3 to 17f5344 Compare June 15, 2023 18:52
Comment thread src/Microsoft.OData.Cli/GenerateCommand.cs Outdated
Comment thread src/Microsoft.OData.Cli/Models/CliUserSettings.cs Outdated
/// <param name="configValue">Source value to use if not null or empty</param>
/// <param name="alternateValue">Alternate value to use if <paramref name="configValue"/> is null or empty</param>
/// <returns><paramref name="configValue"/> if not null or empty, otherwise <paramref name="alternateValue"/></returns>
private static string GetConfigValue(string configValue, string alternateValue)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this method necessary? I don't see how it's any better than the statement var value = string.IsNullOrEmpty(configValue) ? configValue : alternateValue. Also the name of the method is confusing given what it actually does. I thought it retrieving a value from a config store.

Copy link
Copy Markdown
Contributor Author

@gregwinterstein gregwinterstein Aug 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Method removed and replaced with ternary conditional.

Comment thread src/Microsoft.OData.Cli/GenerateCommand.cs Outdated
{
CliConnectedServiceJsonFileData configFileData = null;

if (!string.IsNullOrWhiteSpace(fileName))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should throw an exception when the fileName is null, instead of returning null.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ConnectedServiceFile is not a required parameter and can be null/empty and that should not be an exception. If there is no ConnectedServiceFile parameter on the command-line, all of the configuration for the code generation will come from other command-line parameters.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: If the fileName is null, maybe we shouldn't call this method in the first place then?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refactored GenerateCommand to avoid calling ReadConfigFile with a null fileName in f561b4c

Comment thread src/Microsoft.OData.Cli/GenerateCommand.cs Outdated
Comment thread src/Microsoft.OData.Cli/GenerateCommand.cs Outdated
Comment thread src/Microsoft.OData.Cli/GenerateCommand.cs Outdated
@gregwinterstein gregwinterstein force-pushed the fix/338-odata-cli-ConnectedService.json branch from 17f5344 to a38b036 Compare August 9, 2023 23:17
{
CliConnectedServiceJsonFileData configFileData = null;

if (!string.IsNullOrWhiteSpace(fileName))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: If the fileName is null, maybe we shouldn't call this method in the first place then?

Comment thread src/Microsoft.OData.CodeGen/Models/CliUserSettings.cs
{
[DataContract]
public class UserSettings : INotifyPropertyChanged
public class UserSettings : CliUserSettings
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: maybe: public class ConnectedServiceUserSettings : UserSettings

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed classes in c17c97d and ea9b9a8

@gregwinterstein gregwinterstein force-pushed the fix/338-odata-cli-ConnectedService.json branch from f561b4c to 02dba47 Compare August 22, 2023 20:44
@gregwinterstein
Copy link
Copy Markdown
Contributor Author

Rebased to resolve conflicts in GenerateCommand.cs

@gathogojr gathogojr force-pushed the fix/338-odata-cli-ConnectedService.json branch from 02dba47 to f510319 Compare September 25, 2023 06:32
Comment thread src/ODataConnectedService.Shared/Models/ConnectedServiceUserSettings.cs Outdated
@gregwinterstein gregwinterstein force-pushed the fix/338-odata-cli-ConnectedService.json branch from f510319 to d894d1b Compare October 2, 2023 19:18
Copy link
Copy Markdown
Contributor

@gathogojr gathogojr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gregwinterstein Thank you for your pull request contribution. Sorry it took a bit of time to get round to doing a thorough review. Please take a look at my review comments at your earliest convenience.

Comment thread src/Microsoft.OData.Cli/GenerateCommand.cs Outdated
Comment thread src/Microsoft.OData.Cli/GenerateCommand.cs Outdated
Comment thread src/Microsoft.OData.Cli/GenerateCommand.cs Outdated
Comment thread src/Microsoft.OData.Cli/GenerateCommand.cs Outdated
Comment thread src/Microsoft.OData.Cli/GenerateCommand.cs Outdated
Comment thread src/ODataConnectedService.Shared/ViewModels/ConfigODataEndpointViewModel.cs Outdated
Comment thread src/ODataConnectedService.Shared/ViewModels/OperationImportsViewModel.cs Outdated
Comment thread src/ODataConnectedService.Shared/ViewModels/SchemaTypesViewModel.cs Outdated
Comment thread src/ODataConnectedService.Shared/Views/ConfigODataEndpoint.xaml.cs Outdated
Comment thread test/ODataConnectedService.Tests/ODataConnectedServiceWizardTests.cs Outdated
@KenitoInc
Copy link
Copy Markdown
Contributor

@gregwinterstein Kindly look into review comments by @gathogojr

@gregwinterstein
Copy link
Copy Markdown
Contributor Author

@gregwinterstein Kindly look into review comments by @gathogojr

Hello @KenitoInc , I wlll respond as soon as I can. You all have caught me at an extremely busy time

@gregwinterstein
Copy link
Copy Markdown
Contributor Author

@gregwinterstein Kindly look into review comments by @gathogojr

Hello @kentoinc & @gathogojr, I have reviewed your comments and updated the pull request as requested.

@jvalkeejarvi
Copy link
Copy Markdown

Hi! What is the situation of this PR? I'd really like to get the ConnectedService.json file support for CLI.

@wachugamaina
Copy link
Copy Markdown

Could we add some tests to this Pr ?

Comment thread src/Microsoft.OData.Cli/GenerateOptions.cs
Comment thread src/Microsoft.OData.Cli/Models/ConnectedServiceFileData.cs
Comment thread src/Microsoft.OData.Cli/Models/ConnectedServiceFileData.cs
@gregwinterstein
Copy link
Copy Markdown
Contributor Author

gregwinterstein commented Mar 8, 2024

@wachugamaina

Could we add some tests to this Pr ?

This pull request adds a command-line option for reading generation configuration from ConnectedService.json file
Command-line option: --config-file <connected_service_file_name> or -c <connected_service_file_name>

The overwhelming majority of the changes are in src/Microsoft.OData.Cli/GenerateCommand.cs, inside private methods.

What would you like to see tested in this pull request?
How would you propose to test the changes in this pull request?

@gregwinterstein gregwinterstein force-pushed the fix/338-odata-cli-ConnectedService.json branch from 5b4b1fd to 92e6788 Compare March 11, 2024 15:31
@habbes
Copy link
Copy Markdown
Contributor

habbes commented Mar 22, 2024

We do need to improve the test setup for the CLI, not just this PR (cc @ElizabethOkerio). See: #254

What would be a good starting point in testing the CLI is that the CLI options are correctly transformed into the expected ServiceConfig. And for the purpose of this PR, we would test whether the config in the JSON config files are correctly applied to the ServiceConfig. That would require some refactoring and setting a test project. The next step would be to consider some E2E tests, running the CLI and checking the results. Maybe that's beyond the scope of this PR? If it is, then something we should prioritize with a sense of urgency.

Comment thread src/Microsoft.OData.CodeGen/Models/BaseUserSettings.cs Outdated
Comment thread src/Microsoft.OData.Cli/GenerateCommand.cs Outdated
Comment thread src/Microsoft.OData.Cli/GenerateCommand.cs Outdated
gregwinterstein and others added 18 commits March 26, 2024 07:45
…thogojr

Co-authored-by: John Gathogo <john.gathogo@gmail.com>
Co-authored-by: John Gathogo <john.gathogo@gmail.com>
Co-authored-by: John Gathogo <john.gathogo@gmail.com>
Co-authored-by: John Gathogo <john.gathogo@gmail.com>
Co-authored-by: John Gathogo <john.gathogo@gmail.com>
Co-authored-by: John Gathogo <john.gathogo@gmail.com>
Co-authored-by: John Gathogo <john.gathogo@gmail.com>
Co-authored-by: John Gathogo <john.gathogo@gmail.com>
@gregwinterstein gregwinterstein force-pushed the fix/338-odata-cli-ConnectedService.json branch from 2ef77c7 to 46da013 Compare March 26, 2024 14:49
@gathogojr
Copy link
Copy Markdown
Contributor

@gregwinterstein Please take note of the following two review comments. Not sure you saw them since they were collapsed:

@gregwinterstein
Copy link
Copy Markdown
Contributor Author

@gregwinterstein Please take note of the following two review comments. Not sure you saw them since they were collapsed:

* [Add command-line option for ConnectedService.json file #363 (comment)](https://github.com/OData/ODataConnectedService/pull/363#discussion_r1537580774)

* [Add command-line option for ConnectedService.json file #363 (comment)](https://github.com/OData/ODataConnectedService/pull/363#discussion_r1537610589)

@gathogojr Thank you for the reminder. I have replied to both of the comments you mentioned above. Please review.

Copy link
Copy Markdown
Contributor

@gathogojr gathogojr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Thank you for your contribution @gregwinterstein

@gathogojr gathogojr merged commit ff6294e into OData:master Apr 3, 2024
@gregwinterstein gregwinterstein deleted the fix/338-odata-cli-ConnectedService.json branch April 8, 2024 18:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

odata-cli: Support ConnectedService.json Argument list too long: odata-cli

7 participants