OpenAPITools / OpenAPITools/openapi-generator

[BUG]Python generator produces invalid license value in pyproject.toml

Open
#22,106 2 comments 0 reactions 1 assignee View on GitHub

@kay-schecker is already working on this.

Since Sep 29, 2025.

Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

🐛 Bug Report:

Describe the bug

Python generator produces invalid license = "NoLicense" in pyproject.toml, causing python -m build to fail. The value "NoLicense" is not a valid SPDX identifier according to PEP 621 standards.

Steps to Reproduce

Steps to reproduce the behavior:

  1. Create an OpenAPI spec without a license field (or with a non-standard license)
  2. Generate Python client using:
    openapi-generator-cli generate -i spec.json -c openapi.yml -g python -o dist --skip-validate-spec
    
  3. Navigate to the generated dist directory
  4. Run python -m build
  5. See error:
    configuration error: `project.license` must be valid exactly by one definition (0 matches found)
    GIVEN VALUE: "NoLicense"
    
Expected behavior

The generator should either:

  • Use a valid SPDX identifier like "UNLICENSED" (proper SPDX term for unlicensed code)
  • Omit the license field entirely from pyproject.toml if no license is specified
  • Use the table format: license = {text = "Proprietary"}

According to PEP 621, the license field must be either:

  • A valid SPDX string identifier
  • {file = "LICENSE"} format
  • {text = "license text"} format

"NoLicense" is not a recognized SPDX identifier and causes the build to fail.

Environment
  • OpenAPI Generator version: 7.14.0 (also occurs in 7.11.0)
  • Generator: python
  • Python version: 3.13
  • Build tool: python -m build
Additional context

Full error traceback:

ValueError: invalid pyproject.toml config: `project.license`.
configuration error: `project.license` must be valid exactly by one definition (0 matches found):
    - {type: string, format: 'SPDX'}
    - type: table
      keys:
        'file': {type: string}
      required: ['file']
    - type: table
      keys:
        'text': {type: string}
      required: ['text']

Reference: https://peps.python.org/pep-0621/#license

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.