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

encodedName does not apply to discriminator #2915

Open
xiangyan99 opened this issue Nov 13, 2024 · 1 comment
Open

encodedName does not apply to discriminator #2915

xiangyan99 opened this issue Nov 13, 2024 · 1 comment
Assignees

Comments

@xiangyan99
Copy link
Member

I have such code in tsp file https://github.com/Azure/azure-rest-api-specs/blob/6835b53e2d8ba8a41fcf88b1eae56d4ad44ff9fb/specification/search/Azure.Search/models-service.tsp#L6202-L6214:

/**
 * Base type for character filters.
 */
@discriminator("odataType")
model CharFilter {
  /** The discriminator for derived types. */
  #suppress "@azure-tools/typespec-azure-core/no-string-discriminator" "Existing"
  @encodedName("application/json", "@odata.type")
  odataType: string;

  /**
   * The name of the char filter. It must only contain letters, digits, spaces,
   * dashes or underscores, can only start and end with alphanumeric characters, and
   * is limited to 128 characters.
   */
  name: string;
}

I expected odataType can be renamed into @odata.type, including the one in the discriminator.

But the generated openapi.json https://github.com/Azure/azure-rest-api-specs/blob/6835b53e2d8ba8a41fcf88b1eae56d4ad44ff9fb/specification/search/data-plane/Search/stable/2024-07-01/openapi.json#L2899-L2918 only has

"CharFilter": {
      "type": "object",
      "description": "Base type for character filters.",
      "properties": {
        "@odata.type": {
          "type": "string",
          "description": "The discriminator for derived types.",
          "x-ms-client-name": "odataType"
        },
        "name": {
          "type": "string",
          "description": "The name of the char filter. It must only contain letters, digits, spaces,\ndashes or underscores, can only start and end with alphanumeric characters, and\nis limited to 128 characters."
        }
      },
      "discriminator": "odataType",
      "required": [
        "@odata.type",
        "name"
      ]
    },

It still uses "discriminator": "odataType".

The entire project can be found at https://github.com/Azure/azure-rest-api-specs/tree/search_tsp/specification/search/Azure.Search

@msyyc msyyc self-assigned this Nov 14, 2024
@iscai-msft
Copy link
Contributor

@xiangyan99 since this is an openapi emitter issue, you should open this issue in the TypeSpec repo. I also confirmed this isn't an issue on the python emitter, we're generating with wire name @odata.type. Would you be ok if I transferred this to the typespec repo?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants