Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.4.1] - 2026-03-??

- Fix handling of `enum` without declared `type`, like reported in [#64](https://github.com/Neoteroi/essentials-openapi/issues/64) by @jan-ldwg.

## [1.4.0] - 2026-03-07 :copilot:

- Add OAS 3.1 support, cross-version warnings, and fix nullable spacing, by @dcode.
Expand Down
2 changes: 1 addition & 1 deletion openapidocs/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
__version__ = "1.4.0"
__version__ = "1.4.1"
VERSION = __version__
5 changes: 5 additions & 0 deletions openapidocs/mk/v3/examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,11 @@ def get_example_from_schema(schema) -> Any:
if isinstance(examples, list) and examples:
return examples[0]

# enum without explicit type - return the first value directly
enum = schema.get("enum")
if isinstance(enum, list) and enum:
return enum[0]

# does it have a type?
handlers_types: List[Type[SchemaExampleHandler]] = list(
get_subclasses(SchemaExampleHandler)
Expand Down
3 changes: 3 additions & 0 deletions tests/test_oas31.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,9 @@ class TestGetExampleFromSchemaAnnotations:
({"type": "boolean", "enum": [False]}, False),
# enum on string (pre-existing behaviour still works)
({"type": "string", "enum": ["active", "inactive"]}, "active"),
# enum without explicit type (valid JSON Schema)
({"enum": ["active", "inactive"]}, "active"),
({"enum": [1, 2, 3]}, 1),
],
)
def test_examples_and_enum(self, schema, expected):
Expand Down