Skip to content

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

@vikbhas

Description

@vikbhas

🐛 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

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions