Skip to content

Commit

Permalink
Route model fixes Azure#1
Browse files Browse the repository at this point in the history
  • Loading branch information
alankashiwa committed Jun 30, 2022
1 parent 68c897c commit 2d27bab
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 75 deletions.
28 changes: 10 additions & 18 deletions sdk/maps/maps-route/review/maps-route.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export type ComputeTravelTime = string;
export type DelayMagnitude = string;

// @public
export type DrivingSide = string;
export type DrivingSide = "LEFT" | "RIGHT";

// @public
export interface EffectiveSetting {
Expand Down Expand Up @@ -181,12 +181,6 @@ export enum KnownDelayMagnitude {
Unknown = "0"
}

// @public
export enum KnownDrivingSide {
Left = "LEFT",
Right = "RIGHT"
}

// @public
export enum KnownGuidanceInstructionType {
DirectionInfo = "DIRECTION_INFO",
Expand Down Expand Up @@ -421,11 +415,6 @@ export type RequireAtLeastOne<T> = {
[K in keyof T]-?: Required<Pick<T, K>> & Partial<Pick<T, Exclude<keyof T, K>>>;
}[keyof T];

// @public
export type RequireOnlyOne<T> = {
[K in keyof T]-?: Required<Pick<T, K>> & Partial<Record<Exclude<keyof T, K>, undefined>>;
}[keyof T];

// @public
export type ResponseSectionType = string;

Expand Down Expand Up @@ -625,12 +614,15 @@ export interface RouteRange {
}

// @public
export type RouteRangeBudget = RequireOnlyOne<{
fuelBudgetInLiters?: number;
energyBudgetInKwH?: number;
timeBudgetInSec?: number;
distanceBudgetInMeters?: number;
}>;
export type RouteRangeBudget = {
fuelBudgetInLiters: number;
} | {
energyBudgetInKwH: number;
} | {
timeBudgetInSec: number;
} | {
distanceBudgetInMeters: number;
};

// @public
export type RouteRangeOptions = RouteBaseOptions & OperationOptions;
Expand Down
20 changes: 2 additions & 18 deletions sdk/maps/maps-route/src/generated/models/index.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion sdk/maps/maps-route/src/generated/models/mappers.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion sdk/maps/maps-route/src/models/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ export {
KnownVehicleEngineType,
KnownVehicleLoadType,
KnownWindingnessLevel,
KnownDrivingSide,
KnownGuidanceInstructionType,
KnownGuidanceManeuver,
KnownJunctionType,
Expand Down
74 changes: 37 additions & 37 deletions sdk/maps/maps-route/src/models/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -286,46 +286,46 @@ export interface RouteDirectionsOptions extends RouteBaseOptions {
report?: Report;
}

/**
* RequireOnlyOne helps create a type where only one of the properties of an interface is required to exist.
*/
export type RequireOnlyOne<T> = {
[K in keyof T]-?: Required<Pick<T, K>> & Partial<Record<Exclude<keyof T, K>, undefined>>;
}[keyof T];

/**
* Budget for the route range request. One and only one budget must be provided.
*/
export type RouteRangeBudget = RequireOnlyOne<{
/**
* Fuel budget in liters that determines maximal range which can be travelled using the specified Combustion Consumption Model.
* When fuelBudgetInLiters is used, it is mandatory to specify a detailed Combustion Consumption Model.
*
* Exactly one budget (fuelBudgetInLiters, energyBudgetInKwH, timeBudgetInSec, or distanceBudgetInMeters) must be used.
*/
fuelBudgetInLiters?: number;
/**
* Electric energy budget in kilowatt hours (kWh) that determines maximal range which can be travelled using the specified Electric Consumption Model.
* When energyBudgetInkWh is used, it is mandatory to specify a detailed Electric Consumption Model.
*
* Exactly one budget (fuelBudgetInLiters, energyBudgetInKwH, timeBudgetInSec, or distanceBudgetInMeters) must be used.
*/
energyBudgetInKwH?: number;
/**
* Time budget in seconds that determines maximal range which can be travelled using driving time.
* The Consumption Model will only affect the range when routeType is eco.
*
* Exactly one budget (fuelBudgetInLiters, energyBudgetInKwH, timeBudgetInSec, or distanceBudgetInMeters) must be used.
*/
timeBudgetInSec?: number;
/**
* Distance budget in meters that determines maximal range which can be travelled using driving distance.
* The Consumption Model will only affect the range when routeType is eco.
*
* Exactly one budget (fuelBudgetInLiters, energyBudgetInKwH, timeBudgetInSec, or distanceBudgetInMeters) must be used.
*/
distanceBudgetInMeters?: number;
}>;
export type RouteRangeBudget =
| {
/**
* Fuel budget in liters that determines maximal range which can be travelled using the specified Combustion Consumption Model.
* When fuelBudgetInLiters is used, it is mandatory to specify a detailed Combustion Consumption Model.
*
* Exactly one budget (fuelBudgetInLiters, energyBudgetInKwH, timeBudgetInSec, or distanceBudgetInMeters) must be used.
*/
fuelBudgetInLiters: number;
}
| {
/**
* Electric energy budget in kilowatt hours (kWh) that determines maximal range which can be travelled using the specified Electric Consumption Model.
* When energyBudgetInkWh is used, it is mandatory to specify a detailed Electric Consumption Model.
*
* Exactly one budget (fuelBudgetInLiters, energyBudgetInKwH, timeBudgetInSec, or distanceBudgetInMeters) must be used.
*/
energyBudgetInKwH: number;
}
| {
/**
* Time budget in seconds that determines maximal range which can be travelled using driving time.
* The Consumption Model will only affect the range when routeType is eco.
*
* Exactly one budget (fuelBudgetInLiters, energyBudgetInKwH, timeBudgetInSec, or distanceBudgetInMeters) must be used.
*/
timeBudgetInSec: number;
}
| {
/**
* Distance budget in meters that determines maximal range which can be travelled using driving distance.
* The Consumption Model will only affect the range when routeType is eco.
*
* Exactly one budget (fuelBudgetInLiters, energyBudgetInKwH, timeBudgetInSec, or distanceBudgetInMeters) must be used.
*/
distanceBudgetInMeters: number;
};

/** Options for retrieving route range */
export type RouteRangeOptions = RouteBaseOptions & OperationOptions;
Expand Down
17 changes: 17 additions & 0 deletions sdk/maps/maps-route/swagger/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -253,4 +253,21 @@ directive:
transform: >
$ = { "$ref": "#/definitions/RouteSummary" };
- remove-model: RouteLegSummary
- from: swagger-document
where: $.definitions.RouteInstruction.properties.drivingSide
transform: >
$["x-ms-enum"] = {
"name": "DrivingSide",
"modelAsString": false,
"values": [
{
"value": "LEFT",
"description": "Left side."
},
{
"value": "RIGHT",
"description": "Right side."
}
]
};
```

0 comments on commit 2d27bab

Please sign in to comment.