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

[core-http] Find additionalProperties in referenced mapper #11473

Merged
merged 2 commits into from Sep 25, 2020
Merged

[core-http] Find additionalProperties in referenced mapper #11473

merged 2 commits into from Sep 25, 2020

Conversation

joheredi
Copy link
Member

When serializing object using mappers with references to other mappers, core-http doesn't look at the referenced mapper for additionalProperties it only looks for it in the source mapper.

Sample of a referenced mapper:

export const MonitorBase: CompositeMapper = {
  type: {
    name: "Composite",
    className: "MonitorBase",
    modelProperties: {
      baseType: {
        serializedName: "baseType",
        type: {
          name: "String"
        }
      },
      baseData: {
        serializedName: "baseData",
        type: {
          name: "Composite",
          className: "MonitorDomain" // this is a reference to MonitorDomainMapper
        }
      }
    }
  }
};

export const MonitorDomain: CompositeMapper = {
  type: {
    name: "Composite",
    className: "MonitorDomain",
    additionalProperties: { type: { name: "Object" } },
    modelProperties: {
      test: {
        serializedName: "test",
        type: {
          name: "String"
        }
      }
    }
  }
};

This PR modifies the serializer and deserializer so that they also look at the referenced mapper for additionalProperties and ports the changes to core-client

Copy link
Member

@xirzec xirzec left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change looks good! Thanks for adding test coverage too! 👍

Copy link
Member

@bterlson bterlson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems good to me.

markwolff pushed a commit to markwolff/azure-rest-api-specs that referenced this pull request Sep 24, 2020
Related to Azure/azure-sdk-for-js#11473

The JS exporter requires additional polymorphism hints to completely serialize `baseData`. For now, `additionalProperties` should be passed until something like `oneOf` becomes available.
markwolff added a commit to Azure/azure-rest-api-specs that referenced this pull request Sep 24, 2020
Related to Azure/azure-sdk-for-js#11473

The JS exporter requires additional polymorphism hints to completely serialize `baseData`. For now, `additionalProperties` should be passed until something like `oneOf` becomes available.
@joheredi joheredi merged commit 2ecfb57 into Azure:master Sep 25, 2020
deyaaeldeen pushed a commit to deyaaeldeen/azure-sdk-for-js that referenced this pull request Sep 25, 2020
* Look for additional properties in referenced mapper

* Format
lmazuel pushed a commit to Azure/azure-rest-api-specs that referenced this pull request Oct 5, 2020
Related to Azure/azure-sdk-for-js#11473

The JS exporter requires additional polymorphism hints to completely serialize `baseData`. For now, `additionalProperties` should be passed until something like `oneOf` becomes available.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants