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

Python APIView: public members of Python classes do not show #1964

Closed
tjprescott opened this issue Sep 1, 2021 · 4 comments
Closed

Python APIView: public members of Python classes do not show #1964

tjprescott opened this issue Sep 1, 2021 · 4 comments
Assignees
Labels

Comments

@tjprescott
Copy link
Member

I have a Python class that creates a bunch of public properties in its initializer, but APIView does not display any of them.

class MyClass:

  def __init__(self, **kwargs):
    self.foo = kwargs.get('foo', None)

It would seem like this would severely limit the value of APIView for Python. I tried to use it to verify that regenerating Swagger only added a single new property, but instead it showed no diff.

@tjprescott
Copy link
Member Author

tjprescott commented Sep 3, 2021

If I change the docstrings from :param to :ivar then they appear in APIView. However, autorest generates models, some with :param and others with :ivar. @iscai-msft can you shed some light on how it makes that distinction?

@tjprescott
Copy link
Member Author

I found this: https://github.com/Azure/autorest.python/blob/4f33cb88a9480a9a743f4318c3c911b4a7725056/autorest/codegen/serializers/model_base_serializer.py#L54

   def prop_documentation_string(prop: Property) -> str:
        # building the param line of the property doc
        if prop.constant or prop.readonly:
            param_doc_string = f":ivar {prop.name}:"
        else:
            param_doc_string = f":param {prop.name}:"

I don't know the rationale for why constants are ivar and everything else is param, but assuming it is sound, should APIView also expose params? Or should we somehow examine the init to determine what are actually properties, since it's entirely possible an init param could be consumed and not set on the object with self.foo.

@iscai-msft
Copy link

@tjprescott param basically means we accept this as an input parameter. ivar means it's a variable. Sometimes, the inputted param will also end up being a variable. Hope this clears it up!

@tjprescott
Copy link
Member Author

Azure/autorest.python#1026 fixes this issue. Closing.

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

No branches or pull requests

4 participants