Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
darkoa-msft opened this issue Aug 12, 2024 · 0 comments
Open

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

darkoa-msft opened this issue Aug 12, 2024 · 0 comments
Labels
openapi-to-tsp Tracks OpenAPI to Cadl converter issues

Comments

@darkoa-msft
Copy link
Member

darkoa-msft commented Aug 12, 2024

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[];
}
@pshao25 pshao25 added the openapi-to-tsp Tracks OpenAPI to Cadl converter issues label Sep 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
openapi-to-tsp Tracks OpenAPI to Cadl converter issues
Projects
None yet
Development

No branches or pull requests

2 participants