question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Python] Autorest generates a method signature with twice the same parameter

See original GitHub issue

This creates invalid code:

    def resend_request_emails(
            self, resource_group_name, name, name=None, custom_headers=None, raw=False, **operation_config):
        """Verify domain ownership for this certificate order.
        Verify domain ownership for this certificate order.
        :param resource_group_name: Name of the resource group to which the
         resource belongs.
        :type resource_group_name: str
        :param name: Certificate order name
        :type name: str
        :param name: Name of the object.
        :type name: str

Based on the docstring, it seems there is two differents objects that wants the same parameter name, but obviously it not possible.

Generated with latest Autorest (20170114) and WebApp composite client. Method is here:

       "parameters": [
          {
            "$ref": "#/parameters/resourceGroupNameParameter"
          },
          {
            "name": "name",
            "in": "path",
            "description": "Certificate order name",
            "required": true,
            "type": "string"
          },
          {
            "name": "nameIdentifier",
            "in": "body",
            "description": "Email address",
            "required": true,
            "schema": {
              "$ref": "#/definitions/NameIdentifier"
            }
          },
...
    "NameIdentifier": {
      "description": "Identifies an object.",
      "type": "object",
      "properties": {
        "name": {
          "description": "Name of the object.",
          "type": "string"
        }
      }
    },

Python code is here.

Autorest cmd line: mono /tmp/tmpwl8glpmr/autorest/tools/AutoRest.exe -i /git-restapi/arm-web/compositeWebAppClient.json -o /tmp/tmpwl8glpmr/compositeWebAppClient.json -AddCredentials True -CodeGenerator Azure.Python -Header MICROSOFT_MIT_NO_VERSION -Modeler CompositeSwagger -Namespace azure.mgmt.web -PackageVersion 0.31.0 -ft 2

FYI @annatisch @fearthecowboy @yugangw-msft

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
fearthecowboycommented, Jan 31, 2017

Ah. Ok, that’ll help.

Back on it!

1reaction
fearthecowboycommented, Jan 25, 2017

This would have been handled in the core; duplicate names get disambiguated pretty early.

I think that it’s sneaking by because of auto flattening which happens later. (which happens quite a bit later. )

I’m going to have to debug into this and see why it’s not getting caught when the params are added back into the collection.

Read more comments on GitHub >

github_iconTop Results From Across the Web

autorest/readme.md at main - extensions - GitHub
After using the "x-ms-parameter-location": "method" extension the generated client will have a method that looks like this: Notice that resourceGroupName is the ...
Read more >
Why can't two methods be declared with the same signature ...
I get a compile error that states that the class already defines a member with the same parameter types. (Obviously the way I'm...
Read more >
Generating Clients with AutoRest - Azure documentation
This guide tells you how to generate code from your OpenAPI definition using AutoRest. We'll take this incrementally, working on first how to...
Read more >
Generating clients for your APIs with AutoRest
They've created and open sourced a tool called [AutoRest](https://github.com/Azure/autorest) that can generate client side code from the Swagger document ...
Read more >
How to use AutoRest with RDP - Refinitiv Developer Community
AutoRest Overview. AutoRest is an OpenAPI (Swagger) specification code generator. It is an open-source tool generating client libraries for accessing RESTful ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found