Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ The project is very much Work In Progress and will be published on maven central

# Release Notes
BOAT is still under development and subject to change.
## 0.17.4
* Boat Angular generator
* New format for Angular mocks, which are now export an array with responses.
## 0.17.3
* Boat Angular generator
* Map the `Set` type to `Array` by default to avoid breaking changes vs clients generated with 0.16.x.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ public class BoatAngularGenerator extends AbstractTypeScriptClientCodegen {
public static final String WITH_MOCKS = "withMocks";

public static final String NG_VERSION = "ngVersion";
public static final String FOUNDATION_VERSION = "foundationVersion";
public static final String SPEC_VERSION = "specVersion";
public static final String SPEC_ARTIFACT_ID = "specArtifactId";
public static final String SPEC_GROUP_ID = "specGroupId";
Expand All @@ -75,12 +74,13 @@ public class BoatAngularGenerator extends AbstractTypeScriptClientCodegen {
public static final String PATH_NAME_KEY = "pathName";
public static final String HAS_EXAMPLES = "hasExamples";
public static final String PATTERN = "pattern";
protected String foundationVersion = "6.6.7";
protected String ngVersion = "10.0.0";
protected String serviceSuffix = "Service";
protected String serviceFileSuffix = ".service";
protected String modelFileSuffix = "";

private static final String MOCKS_ARRAY_TEMPLATE_NAME = "apiMocks.array.mustache";

public BoatAngularGenerator() {
super();

Expand Down Expand Up @@ -109,7 +109,6 @@ public BoatAngularGenerator() {
"Setting this property to true will generate mocks out of the examples.",
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(API_MODULE_PREFIX, "The prefix of the generated ApiModule."));
this.cliOptions.add(new CliOption(SERVICE_SUFFIX, "The suffix of the generated service.").defaultValue(this.serviceSuffix));
this.cliOptions.add(new CliOption(BUILD_DIST, "Path to build package to"));
Expand All @@ -119,6 +118,16 @@ public BoatAngularGenerator() {

}

@Override
public String apiFilename(String templateName, String tag) {
String suffix = apiTemplateFiles().get(templateName);
String folder = templateName.equals(MOCKS_ARRAY_TEMPLATE_NAME) ? mocksArrayFolder() : apiFileFolder();
return folder + File.separator + toApiFilename(tag) + suffix;
}

protected String mocksArrayFolder() {
return outputFolder + File.separator + "mocks";
}

@Override
public void preprocessOpenAPI(OpenAPI openAPI) {
Expand Down Expand Up @@ -191,15 +200,6 @@ public void processOpts() {
() -> applyAngularVersion(this.ngVersion)
);

processOpt(FOUNDATION_VERSION,
value -> additionalProperties.put(FOUNDATION_VERSION, new SemVer(value)),
() -> {
SemVer version = new SemVer(this.foundationVersion);
additionalProperties.put(FOUNDATION_VERSION, version);
log.info("generating code with foundation-ang {} ...", version);
log.info(" (you can select the angular version by setting the additionalProperty foundationVersion)");
});

processOpt(SPEC_VERSION,
value -> {
if(StringUtils.isNotEmpty(value)) {
Expand Down Expand Up @@ -231,11 +231,11 @@ public void processOpts() {
() -> {
log.info("generating code without OpenAPI YAML SPEC_GROUP_ID ...");
log.info(" (you can select the specGroupId by setting the additionalProperty specGroupId)");
});
});

processBooleanOpt(WITH_MOCKS, withMocks -> {
if (Boolean.TRUE.equals(withMocks)) {
apiTemplateFiles.put("apiMocks.mustache", ".mocks.ts");
apiTemplateFiles.put(MOCKS_ARRAY_TEMPLATE_NAME, ".mocks.array.js");
}
});

Expand Down
29 changes: 0 additions & 29 deletions boat-scaffold/src/main/templates/boat-angular-mock/README.mustache

This file was deleted.

This file was deleted.

This file was deleted.

2 changes: 0 additions & 2 deletions boat-scaffold/src/main/templates/boat-angular-mock/gitignore

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import { NgModule, ModuleWithProviders, SkipSelf, Optional } from '@angular/core';
import { {{configurationClassName}}{{#withMocks}}, CONFIG_TOKEN{{/withMocks}} } from './configuration';
import { {{configurationClassName}} } from './configuration';
import { HttpClient } from '@angular/common/http';

{{#withMocks}}
import { DataModulesManager } from "@backbase/foundation-ang/data-http";
{{/withMocks}}

@NgModule({
imports: [],
declarations: [],
Expand All @@ -22,11 +18,6 @@ export class {{apiModuleClassName}} {

constructor( @Optional() @SkipSelf() parentModule: {{apiModuleClassName}},
@Optional() http: HttpClient,
{{#withMocks}}
@Optional() dataModulesManager: DataModulesManager | null,
config: {{configurationClassName}},
{{/withMocks}}

) {
if (parentModule) {
throw new Error('{{apiModuleClassName}} is already loaded. Import in your base AppModule only.');
Expand All @@ -35,15 +26,5 @@ export class {{apiModuleClassName}} {
throw new Error('You need to import the HttpClientModule in your AppModule! \n' +
'See also https://github.com/angular/angular/issues/20575');
}

{{#withMocks}}
if (dataModulesManager) {
dataModulesManager.setModuleConfig(CONFIG_TOKEN, {
apiRoot: '',
servicePath: config.basePath || '',
headers: {},
});
}
{{/withMocks}}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
module.exports = [{{#operations}}
{{#operation}}
{
urlPattern: "{{{basePathWithoutHost}}}{{pattern}}",
method: "{{#lambda.uppercase}}{{httpMethod}}{{/lambda.uppercase}}",
responses: [
{{#responses}}
{{#examples}}
{{#isJson}}
{
status: {{{code}}},
body: {{{prettyPrintValue}}}
},
{{/isJson}}
{{^isJson}}
{
status: {{{code}}},
body: "{{#escapeJavascript}}{{{prettyPrintValue}}}{{/escapeJavascript}}"
},
{{/isJson}}
{{/examples}}
{{#hasEmptyBody}}
{
status: {{{code}}},
body: ""
},
{{/hasEmptyBody}}
{{/responses}}
]
},
{{/operation}}
{{/operations}}]
Loading