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 attributes are Optional, despite required in OAS schema #4750

Closed
tarilabs opened this issue May 31, 2024 · 3 comments
Closed

Python attributes are Optional, despite required in OAS schema #4750

tarilabs opened this issue May 31, 2024 · 3 comments
Labels
duplicate This issue or pull request already exists enhancement New feature or request Needs: Attention 👋
Milestone

Comments

@tarilabs
Copy link

What are you generating using Kiota, clients or plugins?

API Client/SDK

In what context or format are you using Kiota?

Mac executable

Client library/SDK language

Python

Describe the bug

I have some OAS properties as required.
When generating Python, the models are rendered with Optional attributes, for example Optional[str] = None.

i.e.:

components:
  schemas:
    Example:
      type: object
      properties:
        name:
          type: string
          example: Example Name
        description:
          type: string
          example: This is an example description.
        value:
          type: number
          example: 42.0
      required:
        - name
        - value

gets rendered as:

@dataclass
class Example(AdditionalDataHolder, Parsable):
    # Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well.
    additional_data: Dict[str, Any] = field(default_factory=dict)

    # The description property
    description: Optional[str] = None
    # The name property
    name: Optional[str] = None
    # The value property
    value: Optional[float] = None

Where instead expected for name and value not to be Optional attributes.

Expected behavior

If an OAS property is required,
in the target language it should be required too.

How to reproduce

Screenshot 2024-05-31 at 11 04 03

first example:

second example:

Open API description file

No response

Kiota Version

1.15.0-preview.202405300001+76b8e1bdaf86000dc03cfdec19528192745ff3b4

Latest Kiota version known to work for scenario above?(Not required)

No response

Known Workarounds

No response

Configuration

No response

Debug output

No response

Other information

This might be also related to:

and other target languages?

@tarilabs tarilabs added status:waiting-for-triage An issue that is yet to be reviewed or assigned type:bug A broken experience labels May 31, 2024
@github-project-automation github-project-automation bot moved this to Needs Triage 🔍 in Kiota May 31, 2024
@andrueastman andrueastman added this to the Backlog milestone Jun 5, 2024
@baywet
Copy link
Member

baywet commented Jun 11, 2024

Hi @tarilabs
Thanks for the detailed information here.
Since it's a design choice on our end which is consistent across languages, and since there's already an issue opened for that #3911, I'm tempted to close it as duplicate to centralize the discussions.
Any objection?

@baywet baywet added duplicate This issue or pull request already exists enhancement New feature or request status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close and removed type:bug A broken experience status:waiting-for-triage An issue that is yet to be reviewed or assigned labels Jun 11, 2024
@baywet baywet moved this from Needs Triage 🔍 to Todo 📃 in Kiota Jun 11, 2024
@baywet baywet moved this from Todo 📃 to In Design 🎨 in Kiota Jun 11, 2024
@tarilabs
Copy link
Author

Hi @baywet no objection, but #3911 in its title looked specific to C#, so that's the reason I created this one :)

👍

@microsoft-github-policy-service microsoft-github-policy-service bot added Needs: Attention 👋 and removed status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close labels Jun 11, 2024
@baywet
Copy link
Member

baywet commented Jun 11, 2024

Thanks I'll update the title over there

@baywet baywet closed this as not planned Won't fix, can't repro, duplicate, stale Jun 11, 2024
@github-project-automation github-project-automation bot moved this from In Design 🎨 to Done ✔️ in Kiota Jun 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists enhancement New feature or request Needs: Attention 👋
Projects
Archived in project
Development

No branches or pull requests

3 participants