Azure / Azure/autorest

[tsp-client convert] `x-ms-identifiers` dropped in some cases

Open
#4,999 0 comments 0 reactions 0 assignees View on GitHub
openapi-to-tsp
Dominant language
TypeSpec
Stars
4.8k
Forks
736
Avg merge
2d 14h
Merged PRs (30d)
1

Description

I am converting an existing OpenAPI swagger to TypeSpec.
In some cases, arrays are not annotated with `x-ms-identifiers` although they exist in the swagger.

**Expected behavior**
All instances of `x-ms-identifiers` from the swagger should appear as ` @OpenAPI.extension("x-ms-identifiers", [])` in tsp.

**Additional context**

Here is the model from the swagger. Note that this model is used as a payload to an ARM action. One of the arrays (_files_) gets properly annotated, the other (_ImportUpdateInput_) does not. The one that does not is being inlined by the converter.

```
"ImportUpdateInput": {
"type": "array",
"description": "Import update input metadata.",
"minItems": 1,
"maxItems": 11,
"items": {
"$ref": "#/definitions/ImportUpdateInputItem"
},
"x-ms-identifiers": []
},
"ImportUpdateInputItem": {
"type": "object",
"description": "Import update input item metadata.",
"properties": {
"importManifest": {
"$ref": "#/definitions/ImportManifestMetadata",
"description": "Import manifest metadata like source URL, file size/hashes, etc."
},
"friendlyName": {
"type": "string",
"description": "Friendly update name.",
"minLength": 1,
"maxLength": 512
},
"files": {
"type": "array",
"description": "One or more update file properties like filename and source URL.",
"minItems": 0,
"maxItems": 10,
"items": {
"$ref": "#/definitions/FileImportMetadata"
},
"x-ms-identifiers": []
}
},
"required": [
"importManifest"
]
},
"ImportUpdateRequest": {
"type": "object",
"description": "Import Update API request body.",
"properties": {
"importUpdateInput": {
"$ref": "#/definitions/ImportUpdateInput"
},
"enableScan": {
"type": "boolean",
"description": "Whether enable anti-malware scan",
"default": false
}
},
"required": [
"importUpdateInput"
]
},
```

And here is the result in tsp
```
/**
* Import Update API request body.
*/
model ImportUpdateRequest {
/**
* Import update input metadata.
*/
importUpdateInput: ImportUpdateInputItem[];

/**
* Whether enable anti-malware scan
*/
enableScan?: boolean;
}

/**
* Import update input item metadata.
*/
model ImportUpdateInputItem {
/**
* Import manifest metadata like source URL, file size/hashes, etc.
*/
importManifest: ImportManifestMetadata;

/**
* Friendly update name.
*/
@maxLength(512)
@minLength(1)
friendlyName?: string;

/**
* One or more update file properties like filename and source URL.
*/
@OpenAPI.extension("x-ms-identifiers", [])
files?: FileImportMetadata[];
}
```

Contributor guide

Open the contributing guide

Research direction

Start by tracing the tsp-client convert path where referenced array schemas are inlined, comparing ImportUpdateInput with the files array in the supplied Swagger model. Done means every Swagger x-ms-identifiers instance, including the inlined ImportUpdateInput array, appears in the generated TypeSpec as an @OpenAPI.extension annotation.

Written by the indexing model from the issue text.

Assessment

Tech stack
openapi
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 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.