Azure / Azure/azure-rest-api-specs

Mark required properties in spec

Open
#10,895 1 comment 0 reactions 0 assignees View on GitHub
Network - Firewall Service Attention
Dominant language
TypeSpec
Stars
3.1k
Forks
5.9k
Avg merge
2d 22h
Merged PRs (30d)
444

Description

I generated typescript classes and interfaces via AutoRest. I noticed many mandatory properties appear optional, because a "required" list is missing for a spec. For example, the "required" (which is missing now) helps AutoRest to generate a correct typescript interface, as below - I believe the two properties are mandatory. Without it, 'addresses' and 'count' become optional.

```json
{
"HubPublicIPAddresses": {
"properties": {
"addresses": {
"type": "array",
"description": "The list of Public IP addresses associated with azure firewall or IP addresses to be retained.",
"items": {
"$ref": "#/definitions/AzureFirewallPublicIPAddress"
}
},
"count": {
"type": "integer",
"format": "int32",
"description": "The number of Public IP addresses associated with azure firewall."
}
},
"required": [
"addresses", "count"
],
"description": "Public IP addresses associated with azure firewall."
},
}
```

```typescript
/**
* Public IP addresses associated with azure firewall.
*/
export interface HubPublicIPAddresses {
/**
* The list of Public IP addresses associated with azure firewall or IP addresses to be retained.
*/
addresses: AzureFirewallPublicIPAddress[];
/**
* The number of Public IP addresses associated with azure firewall.
*/
count: number;
}
```

Contributor guide

Open the contributing guide

Research direction

Start by locating the specification containing the HubPublicIPAddresses definition and compare its properties with the shown required list. Check how AutoRest generates the corresponding TypeScript interface, then verify that addresses and count are emitted as mandatory properties when the specification is corrected.

Written by the indexing model from the issue text.

Assessment

Tech stack
openapi, typescript
Domain
api, backend-api-design
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.