Skip to content

angular generation: Add new additionalProperty - specVersion. Used to…#326

Merged
santam85 merged 9 commits intomainfrom
feature/add-spec-version-prop-ang
Aug 31, 2022
Merged

angular generation: Add new additionalProperty - specVersion. Used to…#326
santam85 merged 9 commits intomainfrom
feature/add-spec-version-prop-ang

Conversation

@brianvabb
Copy link
Copy Markdown
Contributor

Description

Add new additionalProperty - specVersion. Used to link YAML spec version that was used to generate the Angular NPM package

Fixes # nojira

Type of change

  • Feature (adds a new feature or property)

… link YAML sepec versin used to generate the NPM package
"name": "{{{npmName}}}",
"version": "{{{npmVersion}}}",
"description": "OpenAPI client for {{{npmName}}}",
"specVersion": "{{{specVersion}}}",
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.

Should we make this conditional so that it only appears if it has a value?

Also do we want to put this inside a backbase object to avoid potential clashes if package.json adds an official specVersion property in the future for some purpose?

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.

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.

Some test failures, will take another look ^

"version": "{{{npmVersion}}}",
"description": "OpenAPI client for {{{npmName}}}",
"backbase": {
"specVersion": "{{{specVersion}}}"
Copy link
Copy Markdown
Contributor

@santam85 santam85 Aug 31, 2022

Choose a reason for hiding this comment

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

  • let's make it conditional here too

});

processOpt(SPEC_VERSION,
value -> additionalProperties.put(SPEC_VERSION, new SemVer(value)),
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.

Here is where it's trying to parse it as a semver (the new SemVer(value). You could have an if wrapping all of this that only attempts to set the property only if !Strings.isEmpty(value) (which I think is nullsafe)

false));
this.cliOptions.add(new CliOption(NG_VERSION, "The version of Angular. (At least 10.0.0)").defaultValue(this.ngVersion));
this.cliOptions.add(new CliOption(FOUNDATION_VERSION, "The version of foundation-ang library.").defaultValue(this.foundationVersion));
this.cliOptions.add(new CliOption(SPEC_VERSION, "The version of OpenAPI YAML spec used to generate the NPM package.").defaultValue(this.specVersion));
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.

We should remove the default value, otherwise making it conditional in the mustache template has no effect.

false));
this.cliOptions.add(new CliOption(NG_VERSION, "The version of Angular. (At least 10.0.0)").defaultValue(this.ngVersion));
this.cliOptions.add(new CliOption(FOUNDATION_VERSION, "The version of foundation-ang library.").defaultValue(this.foundationVersion));
this.cliOptions.add(new CliOption(SPEC_VERSION, "The version of OpenAPI YAML spec used to generate the NPM package.").defaultValue(this.specVersion));
Copy link
Copy Markdown
Contributor Author

@brianvabb brianvabb Aug 31, 2022

Choose a reason for hiding this comment

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

@ngohungphuc @santam85 this cli option should be included right? So devs know what the property is used for. Just need to remove the .defaultValue(this.specVersion)); part so it's not assigned a default value.


processOpt(SPEC_VERSION,
value -> {
if(!Strings.isEmpty(value)) {
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.

Looking at the build checks, seems there is something wrong with this function syntax? - https://github.com/Backbase/backbase-openapi-tools/runs/8110552249?check_suite_focus=true

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.

Yeah you're right. I should've used the StringUtils

@sonarqubecloud
Copy link
Copy Markdown

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

92.3% 92.3% Coverage
0.0% 0.0% Duplication

@brianvabb brianvabb requested a review from santam85 August 31, 2022 11:51
@santam85 santam85 merged commit f9be95f into main Aug 31, 2022
@santam85 santam85 deleted the feature/add-spec-version-prop-ang branch August 31, 2022 11:55
public static final String HAS_EXAMPLES = "hasExamples";
public static final String PATTERN = "pattern";
protected String foundationVersion = "6.6.7";
protected String specVersion = "1.0.0";
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.

Since this var is being initialised to "1.0.0" will the specVersion also have a default? I think we don't wan't to give it a default so it will be omitted from the package.json if not provided in POM properties.

public static final String HAS_EXAMPLES = "hasExamples";
public static final String PATTERN = "pattern";
protected String foundationVersion = "6.6.7";
protected String specVersion = "1.0.0";
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.

I'm not sure it's a good idea to default to a particular version; it will create incorrect results for people who are not setting this property.

additionalProperties.put(SPEC_VERSION, new SemVer(value));
}
},
() -> {
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.

Again, I'm not sure we should do anything at all when the user does not provide a value.

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.

fixed that in main

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.

4 participants