|
| 1 | +--- |
| 2 | +title: License |
| 3 | +--- |
| 4 | + |
| 5 | +import { ClientTabs, ClientTabItem } from "@components/client-tabs"; |
| 6 | + |
| 7 | +This page explains how the license info is generated in the client code. |
| 8 | + |
| 9 | +## Azure license |
| 10 | + |
| 11 | +For Azure scenarios, client code will always use the MIT license and include the license info in the header of the generated code or in a separate file depending on the language. |
| 12 | + |
| 13 | +For example, this is the license comment in the generated code of a Java client: |
| 14 | + |
| 15 | +```java |
| 16 | +// Copyright (c) Microsoft Corporation. All rights reserved. |
| 17 | +// Licensed under the MIT License. |
| 18 | +``` |
| 19 | + |
| 20 | +This is the `LICENSE` file of a Python client library: |
| 21 | + |
| 22 | +```text |
| 23 | +Copyright (c) Microsoft Corporation |
| 24 | +
|
| 25 | +Permission is hereby granted, free of charge, to any person obtaining a copy |
| 26 | +of this software and associated documentation files (the “Software”), to deal |
| 27 | +in the Software without restriction, including without limitation the rights |
| 28 | +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 29 | +copies of the Software, and to permit persons to whom the Software is |
| 30 | +furnished to do so, subject to the following conditions: |
| 31 | +
|
| 32 | +The above copyright notice and this permission notice shall be included in |
| 33 | +all copies or substantial portions of the Software. |
| 34 | +
|
| 35 | +THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 36 | +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 37 | +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 38 | +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 39 | +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 40 | +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
| 41 | +THE SOFTWARE. |
| 42 | +``` |
| 43 | + |
| 44 | +## Unbranded license |
| 45 | + |
| 46 | +For unbranded scenarios, client code will have no license info if there is no license configuration in `tspconfig.yaml`. |
| 47 | +Spec authors can set the license info with the `license` configuration in the `tspconfig.yaml`: |
| 48 | + |
| 49 | +```yaml |
| 50 | +license: |
| 51 | + name: <License name. We have built-in "MIT License", "Apache License 2.0", "BSD 3-Clause License", "MPL 2.0", "GPL-3.0", and "LGPL-3.0". For other licenses, you need to set the link, header, and description manually.> |
| 52 | + company: <Company name used in copyright> |
| 53 | + link: <License link> |
| 54 | + header: <License header in the generated code> |
| 55 | + description: <License description in the separate license file> |
| 56 | +``` |
| 57 | +
|
| 58 | +For example, if you configure the license like the following, you will get the same license info as Azure scenarios: |
| 59 | +
|
| 60 | +```yaml |
| 61 | +emit: |
| 62 | + - "@azure-tools/typespec-python" |
| 63 | + - "@azure-tools/typespec-java" |
| 64 | +options: |
| 65 | + "@azure-tools/typespec-python": |
| 66 | + license: |
| 67 | + name: "MIT License" |
| 68 | + company: "Microsoft Corporation" |
| 69 | + "@azure-tools/typespec-java": |
| 70 | + license: |
| 71 | + name: "MIT License" |
| 72 | + company: "Microsoft Corporation" |
| 73 | +``` |
0 commit comments