Skip to content

Commit

Permalink
Fix polymorphic skip normalization (#873)
Browse files Browse the repository at this point in the history
* Fix Skip Normalize for polymorfic objects

* update
  • Loading branch information
joheredi authored Feb 23, 2021
1 parent 209a85a commit 5d26b43
Show file tree
Hide file tree
Showing 8 changed files with 2,226 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/generators/modelsGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,7 @@ function getProperties(
return properties
.filter(property => !property.isDiscriminator)
.map<PropertySignatureStructure>(property => ({
name: property.name,
name: `"${property.name}"`,
hasQuestionToken: !property.required,
isReadonly: property.readOnly,
type: getTypename(property),
Expand Down Expand Up @@ -743,12 +743,14 @@ function withDiscriminator(

const discProps = keys(discriminatorValues).map<PropertySignatureStructure>(
key => {
const name = normalizeName(key, NameType.Property);
// Remove enclosing quotes from the key to get the real property name
const propertyName = key.replace(/(^")|("$)/g, "");
const name = normalizeName(propertyName, NameType.Property);
return {
docs: [
`Polymorphic discriminator, which specifies the different types this object can be`
],
name,
name: `"${name}"`,
type: discriminatorValues[key].map(disc => `"${disc}"`).join(" | "),
kind: StructureKind.PropertySignature
};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export * from "./models";
export { MediaServicesClient } from "./mediaServicesClient";
export { MediaServicesClientContext } from "./mediaServicesClientContext";
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { MediaServicesClientContext } from "./mediaServicesClientContext";
import { MediaServicesClientOptionalParams } from "./models";

export class MediaServicesClient extends MediaServicesClientContext {
/**
* Initializes a new instance of the MediaServicesClient class.
* @param options The parameter options
*/
constructor(options?: MediaServicesClientOptionalParams) {
super(options);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import * as coreHttp from "@azure/core-http";
import { MediaServicesClientOptionalParams } from "./models";

const packageName = "@azure/media-services";
const packageVersion = "1.0.0-preview1";

export class MediaServicesClientContext extends coreHttp.ServiceClient {
/**
* Initializes a new instance of the MediaServicesClientContext class.
* @param options The parameter options
*/
constructor(options?: MediaServicesClientOptionalParams) {
// Initializing default values for options
if (!options) {
options = {};
}

if (!options.userAgent) {
const defaultUserAgent = coreHttp.getDefaultUserAgentValue();
options.userAgent = `${packageName}/${packageVersion} ${defaultUserAgent}`;
}

super(undefined, options);

this.requestContentType = "application/json; charset=utf-8";

this.baseUri = options.endpoint;
}
}
Loading

0 comments on commit 5d26b43

Please # to comment.