License
This page explains how the license info is generated in the client code.
Azure license
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.
For example, this is the license comment in the generated code of a Java client:
// Copyright (c) Microsoft Corporation. All rights reserved.// Licensed under the MIT License.This is the LICENSE file of a Python client library:
Copyright (c) Microsoft Corporation
Permission is hereby granted, free of charge, to any person obtaining a copyof this software and associated documentation files (the “Software”), to dealin the Software without restriction, including without limitation the rightsto use, copy, modify, merge, publish, distribute, sublicense, and/or sellcopies of the Software, and to permit persons to whom the Software isfurnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included inall copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS ORIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THEAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHERLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS INTHE SOFTWARE.Unbranded license
For unbranded scenarios, client code will have no license info if there is no license configuration in tspconfig.yaml.
Spec authors can set the license info with the license configuration in the tspconfig.yaml, the configuration is as follows:
license: name: <License name. This is required. We have built-in "MIT License", "Apache License 2.0", "BSD 3-Clause License", "MPL 2.0", "GPL-3.0", and "LGPL-3.0". If you use build-in license, you only need to set the name and company. For other licenses, you need to set the name, company, link, header, and description manually.> company: <Company name. Optional. For build-in license, it will affect the copyright sentence.> link: <License link. Optional. If you want a customized license, you need to set the link manually.> header: <License header in the generated code. Optional. If you want a customized license, you need to set the header manually.> description: <License description in the separate license file. Optional. If you want a customized license, you need to set the description manually.>For example, if you configure the license using a built-in license:
emit: - "@azure-tools/typespec-python" - "@azure-tools/typespec-java"options: "@azure-tools/typespec-python": license: name: "Apache License 2.0" company: "Microsoft Corporation" "@azure-tools/typespec-java": license: name: "Apache License 2.0" company: "Microsoft Corporation"This is the license comment in the generated code of a Java client:
// Copyright (c) Microsoft Corporation. All rights reserved.// Licensed under the Apache License, Version 2.0.This is the LICENSE file of a Python client library:
Copyright (c) Microsoft Corporation
Licensed under the Apache License, Version 2.0 (the "License");you may not use this file except in compliance with the License.You may obtain a copy of the License at\n
http://www.apache.org/licenses/LICENSE-2.0\n
Unless required by applicable law or agreed to in writing, softwaredistributed under the License is distributed on an "AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.See the License for the specific language governing permissions andlimitations under the License.If you configure the license using a customized license:
emit: - "@azure-tools/typespec-python" - "@azure-tools/typespec-java"options: "@azure-tools/typespec-python": license: name: "Mozilla Public License 2.0" link: "https://www.mozilla.org/en-US/MPL/2.0/" header: "This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/." description: "This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/." "@azure-tools/typespec-java": license: name: "Mozilla Public License 2.0" link: "https://www.mozilla.org/en-US/MPL/2.0/" header: "This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/." description: "This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/."For example, if you configure the license using a built-in license:
emit: - "@azure-tools/typespec-python" - "@azure-tools/typespec-java"options: "@azure-tools/typespec-python": license: name: "Apache License 2.0" company: "Microsoft Corporation" "@azure-tools/typespec-java": license: name: "Apache License 2.0" company: "Microsoft Corporation"This is the license comment in the generated code of a Java client:
// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.This is the LICENSE file of a Python client library:
This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.