-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add cadl ranch model inheritance other test cases for RLC (#2009)
* add-cadl-ranch-mode-inheritacn-other-test-cases * fix inheritance * resolve comments of description
- Loading branch information
Showing
49 changed files
with
2,037 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
...pespec-ts/test/integration/generated/models/inheritance-enum-discriminator/.eslintrc.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"plugins": ["@azure/azure-sdk"], | ||
"extends": ["plugin:@azure/azure-sdk/azure-sdk-base"], | ||
"rules": { | ||
"@azure/azure-sdk/ts-modules-only-named": "warn", | ||
"@azure/azure-sdk/ts-apiextractor-json-types": "warn", | ||
"@azure/azure-sdk/ts-package-json-types": "warn", | ||
"@azure/azure-sdk/ts-package-json-engine-is-present": "warn", | ||
"tsdoc/syntax": "warn" | ||
} | ||
} |
56 changes: 56 additions & 0 deletions
56
...c-ts/test/integration/generated/models/inheritance-enum-discriminator/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# EnumDiscriminator REST client library for JavaScript | ||
|
||
Illustrates inheritance with enum discriminator. | ||
|
||
**Please rely heavily on our [REST client docs](https://github.com/Azure/azure-sdk-for-js/blob/main/documentation/rest-clients.md) to use this library** | ||
|
||
Key links: | ||
|
||
- [Package (NPM)](https://www.npmjs.com/package/@msinternal/model-inheritance-enum-discriminator) | ||
|
||
## Getting started | ||
|
||
### Currently supported environments | ||
|
||
- LTS versions of Node.js | ||
|
||
### Prerequisites | ||
|
||
- You must have an [Azure subscription](https://azure.microsoft.com/free/) to use this package. | ||
|
||
### Install the `@msinternal/model-inheritance-enum-discriminator` package | ||
|
||
Install the EnumDiscriminator REST client REST client library for JavaScript with `npm`: | ||
|
||
```bash | ||
npm install @msinternal/model-inheritance-enum-discriminator | ||
``` | ||
|
||
### Create and authenticate a `EnumDiscriminatorClient` | ||
|
||
To use an [Azure Active Directory (AAD) token credential](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity/samples/AzureIdentityExamples.md#authenticating-with-a-pre-fetched-access-token), | ||
provide an instance of the desired credential type obtained from the | ||
[@azure/identity](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/identity/identity#credentials) library. | ||
|
||
To authenticate with AAD, you must first `npm` install [`@azure/identity`](https://www.npmjs.com/package/@azure/identity) | ||
|
||
After setup, you can choose which type of [credential](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/identity/identity#credentials) from `@azure/identity` to use. | ||
As an example, [DefaultAzureCredential](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/identity/identity#defaultazurecredential) | ||
can be used to authenticate the client. | ||
|
||
Set the values of the client ID, tenant ID, and client secret of the AAD application as environment variables: | ||
AZURE_CLIENT_ID, AZURE_TENANT_ID, AZURE_CLIENT_SECRET | ||
|
||
## Troubleshooting | ||
|
||
### Logging | ||
|
||
Enabling logging may help uncover useful information about failures. In order to see a log of HTTP requests and responses, set the `AZURE_LOG_LEVEL` environment variable to `info`. Alternatively, logging can be enabled at runtime by calling `setLogLevel` in the `@azure/logger`: | ||
|
||
```javascript | ||
const { setLogLevel } = require("@azure/logger"); | ||
|
||
setLogLevel("info"); | ||
``` | ||
|
||
For more detailed instructions on how to enable logs, you can look at the [@azure/logger package docs](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/core/logger). |
18 changes: 18 additions & 0 deletions
18
...ec-ts/test/integration/generated/models/inheritance-enum-discriminator/api-extractor.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json", | ||
"mainEntryPointFilePath": "./types/index.d.ts", | ||
"docModel": { "enabled": true }, | ||
"apiReport": { "enabled": true, "reportFolder": "./review" }, | ||
"dtsRollup": { | ||
"enabled": true, | ||
"untrimmedFilePath": "", | ||
"publicTrimmedFilePath": "./types/model-inheritance-enum-discriminator.d.ts" | ||
}, | ||
"messages": { | ||
"tsdocMessageReporting": { "default": { "logLevel": "none" } }, | ||
"extractorMessageReporting": { | ||
"ae-missing-release-tag": { "logLevel": "none" }, | ||
"ae-unresolved-link": { "logLevel": "none" } | ||
} | ||
} | ||
} |
80 changes: 80 additions & 0 deletions
80
...typespec-ts/test/integration/generated/models/inheritance-enum-discriminator/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
{ | ||
"name": "@msinternal/model-inheritance-enum-discriminator", | ||
"sdk-type": "client", | ||
"author": "Microsoft Corporation", | ||
"version": "1.0.0", | ||
"description": "Model Inheritance Test Service", | ||
"keywords": ["node", "azure", "cloud", "typescript", "browser", "isomorphic"], | ||
"license": "MIT", | ||
"main": "dist/index.js", | ||
"module": "./dist-esm/index.js", | ||
"types": "./types/model-inheritance-enum-discriminator.d.ts", | ||
"repository": "github:Azure/azure-sdk-for-js", | ||
"bugs": { "url": "https://github.com/Azure/azure-sdk-for-js/issues" }, | ||
"files": [ | ||
"dist/", | ||
"dist-esm/", | ||
"types/model-inheritance-enum-discriminator.d.ts", | ||
"README.md", | ||
"LICENSE", | ||
"review/*" | ||
], | ||
"engines": { "node": ">=14.0.0" }, | ||
"scripts": { | ||
"audit": "node ../../../common/scripts/rush-audit.js && rimraf node_modules package-lock.json && npm i --package-lock-only 2>&1 && npm audit", | ||
"build:browser": "echo skipped.", | ||
"build:node": "echo skipped.", | ||
"build:samples": "echo skipped.", | ||
"build:test": "echo skipped.", | ||
"build:debug": "echo skipped.", | ||
"check-format": "prettier --list-different --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"*.{js,json}\" ", | ||
"clean": "rimraf --glob dist dist-browser dist-esm test-dist temp types *.tgz *.log", | ||
"execute:samples": "echo skipped", | ||
"extract-api": "rimraf review && mkdirp ./review && api-extractor run --local", | ||
"format": "prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"*.{js,json}\" ", | ||
"generate:client": "echo skipped", | ||
"integration-test:browser": "echo skipped", | ||
"integration-test:node": "echo skipped", | ||
"integration-test": "echo skipped", | ||
"lint:fix": "eslint package.json api-extractor.json src --ext .ts --fix --fix-type [problem,suggestion]", | ||
"lint": "eslint package.json api-extractor.json src --ext .ts", | ||
"pack": "npm pack 2>&1", | ||
"test:browser": "echo skipped", | ||
"test:node": "echo skipped", | ||
"test": "echo \"Error: no test specified\" && exit 1", | ||
"unit-test": "echo skipped", | ||
"unit-test:node": "echo skipped", | ||
"unit-test:browser": "echo skipped", | ||
"build": "npm run clean && tsc && rollup -c 2>&1 && npm run minify && mkdirp ./review && npm run extract-api", | ||
"minify": "uglifyjs -c -m --comments --source-map \"content='./dist/index.js.map'\" -o ./dist/index.min.js ./dist/index.js" | ||
}, | ||
"sideEffects": false, | ||
"autoPublish": false, | ||
"dependencies": { | ||
"@azure/core-auth": "^1.3.0", | ||
"@azure-rest/core-client": "^1.1.4", | ||
"@azure/core-rest-pipeline": "^1.12.0", | ||
"@azure/logger": "^1.0.0", | ||
"tslib": "^2.2.0" | ||
}, | ||
"devDependencies": { | ||
"@microsoft/api-extractor": "^7.31.1", | ||
"autorest": "latest", | ||
"@types/node": "^14.0.0", | ||
"dotenv": "^16.0.0", | ||
"eslint": "^8.0.0", | ||
"mkdirp": "^2.1.2", | ||
"prettier": "^2.5.1", | ||
"rimraf": "^5.0.0", | ||
"source-map-support": "^0.5.9", | ||
"typescript": "~5.0.0", | ||
"@rollup/plugin-commonjs": "^24.0.0", | ||
"@rollup/plugin-json": "^6.0.0", | ||
"@rollup/plugin-multi-entry": "^6.0.0", | ||
"@rollup/plugin-node-resolve": "^13.1.3", | ||
"rollup": "^2.66.1", | ||
"rollup-plugin-sourcemaps": "^0.6.3", | ||
"uglify-js": "^3.4.9" | ||
}, | ||
"type": "module" | ||
} |
118 changes: 118 additions & 0 deletions
118
...spec-ts/test/integration/generated/models/inheritance-enum-discriminator/rollup.config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT license. | ||
|
||
import nodeResolve from "@rollup/plugin-node-resolve"; | ||
import cjs from "@rollup/plugin-commonjs"; | ||
import sourcemaps from "rollup-plugin-sourcemaps"; | ||
import multiEntry from "@rollup/plugin-multi-entry"; | ||
import json from "@rollup/plugin-json"; | ||
|
||
import nodeBuiltins from "builtin-modules"; | ||
|
||
// #region Warning Handler | ||
|
||
/** | ||
* A function that can determine whether a rollup warning should be ignored. If | ||
* the function returns `true`, then the warning will not be displayed. | ||
*/ | ||
|
||
function ignoreNiseSinonEval(warning) { | ||
return ( | ||
warning.code === "EVAL" && | ||
warning.id && | ||
(warning.id.includes("node_modules/nise") || | ||
warning.id.includes("node_modules/sinon")) === true | ||
); | ||
} | ||
|
||
function ignoreChaiCircularDependency(warning) { | ||
return ( | ||
warning.code === "CIRCULAR_DEPENDENCY" && | ||
warning.importer && | ||
warning.importer.includes("node_modules/chai") === true | ||
); | ||
} | ||
|
||
const warningInhibitors = [ignoreChaiCircularDependency, ignoreNiseSinonEval]; | ||
|
||
/** | ||
* Construct a warning handler for the shared rollup configuration | ||
* that ignores certain warnings that are not relevant to testing. | ||
*/ | ||
function makeOnWarnForTesting() { | ||
return (warning, warn) => { | ||
// If every inhibitor returns false (i.e. no inhibitors), then show the warning | ||
if (warningInhibitors.every((inhib) => !inhib(warning))) { | ||
warn(warning); | ||
} | ||
}; | ||
} | ||
|
||
// #endregion | ||
|
||
function makeBrowserTestConfig() { | ||
const config = { | ||
input: { | ||
include: ["dist-esm/test/**/*.spec.js"], | ||
exclude: ["dist-esm/test/**/node/**"], | ||
}, | ||
output: { | ||
file: `dist-test/index.browser.js`, | ||
format: "umd", | ||
sourcemap: true, | ||
}, | ||
preserveSymlinks: false, | ||
plugins: [ | ||
multiEntry({ exports: false }), | ||
nodeResolve({ | ||
mainFields: ["module", "browser"], | ||
}), | ||
cjs(), | ||
json(), | ||
sourcemaps(), | ||
//viz({ filename: "dist-test/browser-stats.html", sourcemap: true }) | ||
], | ||
onwarn: makeOnWarnForTesting(), | ||
// Disable tree-shaking of test code. In rollup-plugin-node-resolve@5.0.0, | ||
// rollup started respecting the "sideEffects" field in package.json. Since | ||
// our package.json sets "sideEffects=false", this also applies to test | ||
// code, which causes all tests to be removed by tree-shaking. | ||
treeshake: false, | ||
}; | ||
|
||
return config; | ||
} | ||
|
||
const defaultConfigurationOptions = { | ||
disableBrowserBundle: false, | ||
}; | ||
|
||
export function makeConfig(pkg, options) { | ||
options = { | ||
...defaultConfigurationOptions, | ||
...(options || {}), | ||
}; | ||
|
||
const baseConfig = { | ||
// Use the package's module field if it has one | ||
input: pkg["module"] || "dist-esm/src/index.js", | ||
external: [ | ||
...nodeBuiltins, | ||
...Object.keys(pkg.dependencies), | ||
...Object.keys(pkg.devDependencies), | ||
], | ||
output: { file: "dist/index.js", format: "cjs", sourcemap: true }, | ||
preserveSymlinks: false, | ||
plugins: [sourcemaps(), nodeResolve()], | ||
}; | ||
|
||
const config = [baseConfig]; | ||
|
||
if (!options.disableBrowserBundle) { | ||
config.push(makeBrowserTestConfig()); | ||
} | ||
|
||
return config; | ||
} | ||
|
||
export default makeConfig(require("./package.json")); |
Oops, something went wrong.