Skip to content

Comments

Constants as openapi const#1086

Merged
romalytvynenko merged 11 commits intodedoc:mainfrom
apasquini95:constants-as-openapi-const
Feb 15, 2026
Merged

Constants as openapi const#1086
romalytvynenko merged 11 commits intodedoc:mainfrom
apasquini95:constants-as-openapi-const

Conversation

@apasquini95
Copy link
Contributor

As mentioned in #1015, the OpenApi 3.1 standard allows to declare constant values with the const syntax, instead of using the single-value enum schema. This can improve openapi readability and parsers' interpretation of it.

This merge request allows the developer to use this feature, that can be enabled by toggling the scramble.class_constants_as_const config value.

@romalytvynenko
Copy link
Member

I'm wondering, is this PR AI-assisted??

I don't understand why this pr introduces so much changes across all subsystems (type inference, open api generation, configuration) while the only thing it should do is to use const JSON schema keyword when transforming literal types to JSON schema.

@apasquini95
Copy link
Contributor Author

No, no AI was involved. I tried to figure out how to do it by following the EnumCaseType's lifecycle. The configuration was just a plus, since I thought it could be an unnecessary or even unwanted feature for some developers. If you have any suggestion to make it better, I'd be glad to update the PR.

@romalytvynenko
Copy link
Member

@apasquini95 gotcha.

I believe that this PR should be only concerned with 2 things: 1) add const keyword to json schema (generator type), 2) ensure that single literal type is represented with const, not enum.

I see you also attempted changing how class consts fetching work, but there is no need for it. And if in some context it doesn't work, it is a completely different issue then.

@apasquini95
Copy link
Contributor Author

Ok, I'll make another attempt thanks :) What about the configuration flag? Do you think it is unnecessary?

@romalytvynenko
Copy link
Member

@apasquini95 nah, I'd rather just go for it. const is much better representation of literals

@romalytvynenko
Copy link
Member

@apasquini95 thanks!

@romalytvynenko romalytvynenko merged commit fdd0e03 into dedoc:main Feb 15, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants