Skip to content

Commit

Permalink
Adding default domain to hostnames (#2051)
Browse files Browse the repository at this point in the history
* Adding default domain to hostnames

* fixing params for hostnames
  • Loading branch information
javierbo1989 authored Feb 13, 2023
1 parent 3845892 commit c8867b0
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@
Use CORS proxy
</label>
</div>
<div class="form-group">
<label for="includeAllHostnames" class="form-label">
<input type="checkbox" id="includeAllHostnames" name="includeAllHostnames" data-bind="checked: includeAllHostnames" />
Include all hostnames
</label>
</div>
</div>
</div>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@ export class OperationDetailsEditor {
public readonly enableScrollTo: ko.Observable<boolean>;
public readonly defaultSchemaView: ko.Observable<string>;
public readonly useCorsProxy: ko.Observable<boolean>;
public readonly includeAllHostnames: ko.Observable<boolean>;
public readonly showExamples: ko.Observable<boolean>;

constructor() {
this.enableConsole = ko.observable();
this.enableScrollTo = ko.observable();
this.defaultSchemaView = ko.observable();
this.useCorsProxy = ko.observable();
this.includeAllHostnames = ko.observable();
this.showExamples = ko.observable();
}

Expand All @@ -32,12 +34,14 @@ export class OperationDetailsEditor {
public async initialize(): Promise<void> {
this.enableConsole(this.model.enableConsole);
this.useCorsProxy(this.model.useCorsProxy);
this.includeAllHostnames(this.model.includeAllHostnames);
this.enableScrollTo(this.model.enableScrollTo);
this.defaultSchemaView(this.model.defaultSchemaView || "table");
this.showExamples(this.model.showExamples);

this.enableConsole.subscribe(this.applyChanges);
this.useCorsProxy.subscribe(this.applyChanges);
this.includeAllHostnames.subscribe(this.applyChanges);
this.enableScrollTo.subscribe(this.applyChanges);
this.defaultSchemaView.subscribe(this.applyChanges);
this.showExamples.subscribe(this.applyChanges);
Expand All @@ -46,6 +50,7 @@ export class OperationDetailsEditor {
private applyChanges(): void {
this.model.enableConsole = this.enableConsole();
this.model.useCorsProxy = this.useCorsProxy();
this.model.includeAllHostnames = this.includeAllHostnames();
this.model.enableScrollTo = this.enableScrollTo();
this.model.defaultSchemaView = this.defaultSchemaView();
this.model.showExamples = this.showExamples();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export class OperationDetailsViewModelBinder implements ViewModelBinder<Operatio
enableScrollTo: model.enableScrollTo,
defaultSchemaView: model.defaultSchemaView,
useCorsProxy: model.useCorsProxy,
includeAllHostnames: model.includeAllHostnames,
showExamples: model.showExamples,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ export class OperationDetails {
this.definitions = ko.observableArray<TypeDefinition>();
this.defaultSchemaView = ko.observable("table");
this.useCorsProxy = ko.observable();
this.includeAllHostnames = ko.observable();
this.requestUrlSample = ko.computed(() => {

const api = this.api();
Expand Down Expand Up @@ -130,6 +131,9 @@ export class OperationDetails {
@Param()
public useCorsProxy: ko.Observable<boolean>;

@Param()
public includeAllHostnames: ko.Observable<boolean>;

@Param()
public enableScrollTo: boolean;

Expand Down Expand Up @@ -372,7 +376,7 @@ export class OperationDetails {
}

public async loadGatewayInfo(apiName: string): Promise<void> {
const hostnames = await this.apiService.getApiHostnames(apiName);
const hostnames = await this.apiService.getApiHostnames(apiName, this.includeAllHostnames());

if (hostnames.length !== 0) {
this.sampleHostname(hostnames[0]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ export interface OperationDetailsContract extends Contract {
*/
useCorsProxy?: boolean;

/**
* Indicates include all hostnames to the test console.
*/
includeAllHostnames?: boolean;

/**
* Show operation attribute values examples in a column in tables.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ export class OperationDetailsModel {
*/
public useCorsProxy?: boolean;

/**
* Indicates include all hostnames to the test console.
*/
public includeAllHostnames?: boolean;

/**
* Show operation attribute values examples in a column in tables.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export class OperationDetailsModelBinder implements IModelBinder<OperationDetail
model.enableScrollTo = contract.enableScrollTo !== undefined && contract.enableScrollTo === true;
model.defaultSchemaView = contract.defaultSchemaView || "table";
model.useCorsProxy = contract.useCorsProxy;
model.includeAllHostnames = contract.includeAllHostnames;
model.showExamples = contract.showExamples || false;

return model;
Expand All @@ -31,6 +32,7 @@ export class OperationDetailsModelBinder implements IModelBinder<OperationDetail
enableScrollTo: model.enableScrollTo,
defaultSchemaView: model.defaultSchemaView,
useCorsProxy: model.useCorsProxy,
includeAllHostnames: model.includeAllHostnames,
showExamples: model.showExamples,
};

Expand Down
7 changes: 5 additions & 2 deletions src/services/apiService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -538,8 +538,11 @@ export class ApiService {
return page;
}

public async getApiHostnames(apiName: string): Promise<string[]> {
const query = `apis/${apiName}/hostnames`;
public async getApiHostnames(apiName: string, includeAllHostnames: boolean = false): Promise<string[]> {
let query = `apis/${apiName}/hostnames`;
if(includeAllHostnames) {
query+=`?includeAllHostnames=true`
}
const pageOfHostnames = await this.mapiClient.get<Page<Hostname>>(query, [await this.mapiClient.getPortalHeader("getApiHostnames")]);
const hostnameValues = pageOfHostnames.value.map(x => x.properties.value);

Expand Down

0 comments on commit c8867b0

Please sign in to comment.