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

Problems with (C#) models from PayPal Orders OpenAPI #4568

Closed
MihaMarkic opened this issue Apr 29, 2024 · 3 comments
Closed

Problems with (C#) models from PayPal Orders OpenAPI #4568

MihaMarkic opened this issue Apr 29, 2024 · 3 comments
Labels
duplicate This issue or pull request already exists type:bug A broken experience

Comments

@MihaMarkic
Copy link

Here is the PayPal Orders v2 API which I'm trying to generate code for.

Pay attention to Orders schema, which looks something like:

     "order": {
        "type": "object",
        "title": "Order",
        "description": "The order details.",
        "allOf": [
          {
            "$ref": "#/components/schemas/activity_timestamps"
          },
          {
            "properties": {
              "id": {
                "type": "string",
                "description": "The ID of the order.",
                "readOnly": true
              },
              ...

The problem I'm facing is that the Order model doesn't contain any property at all, though it is (probably correctly) a subclass of activity_timestamps.

Generated code:

public class Order : Activity_timestamps, IParsable 
{
    /// <summary>
    /// Creates a new instance of the appropriate class based on discriminator value
    /// </summary>
    /// <returns>A <see cref="Order"/></returns>
    /// <param name="parseNode">The parse node to use to read the discriminator value and create the object</param>
    public static new Order CreateFromDiscriminatorValue(IParseNode parseNode)
    {
        _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode));
        return new Order();
    }
    /// <summary>
    /// The deserialization information for the current model
    /// </summary>
    /// <returns>A IDictionary&lt;string, Action&lt;IParseNode&gt;&gt;</returns>
    public override IDictionary<string, Action<IParseNode>> GetFieldDeserializers()
    {
        return new Dictionary<string, Action<IParseNode>>(base.GetFieldDeserializers())
        {
        };
    }
    /// <summary>
    /// Serializes information the current object
    /// </summary>
    /// <param name="writer">Serialization writer to use to serialize this model</param>
    public override void Serialize(ISerializationWriter writer)
    {
        _ = writer ?? throw new ArgumentNullException(nameof(writer));
        base.Serialize(writer);
    }
}
@github-project-automation github-project-automation bot moved this to Todo 📃 in Kiota Apr 29, 2024
@MihaMarkic
Copy link
Author

Looks like that #4346 is a similar issue

@MihaMarkic
Copy link
Author

Looks like the solution from #4346 works - moving properties out of 'allOf' array to sibling position to allOf fixes it. Code then seems properly generated.
Like

...
"properties: { ... },
"allOf": [{ "$ref": "#/components/schemas/activity_timestamps"}]
...

@baywet
Copy link
Member

baywet commented Apr 29, 2024

Thanks for reaching out and for the detailed analysis. Since this looks extremely similar to the other issue, and since a fix is already in progress, I'm going to go ahead and close it as duplicate. Please follow the other issue to get updates.

@baywet baywet closed this as not planned Won't fix, can't repro, duplicate, stale Apr 29, 2024
@github-project-automation github-project-automation bot moved this from Todo 📃 to Done ✔️ in Kiota Apr 29, 2024
@baywet baywet added type:bug A broken experience duplicate This issue or pull request already exists labels Apr 29, 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 type:bug A broken experience
Projects
Archived in project
Development

No branches or pull requests

2 participants