You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When a property is defined as an object with additionalProperties and no properties are defined, the description is duplicated at both the top-level object and the additionalProperties level.
This does not occur in the following scenarios:
When a description is provided at both the top level and additionalProperties.
This workaround forces the object to render without a additionalProperties (property name*), though it’s not ideal. We cannot omit additionalProperties due to the need for valid examples in TypeSpec.
When additionalProperties contains valid properties, the duplication does not occur.
Expected Behavior
The description should not be duplicated. The additionalProperties section should either stay empty or have a preset description explaining that the property name is user-defined.
Current Behavior
The top-level object description is duplicated at the additionalProperties level when additionalProperties is empty.
Possible Solutions
Create a separate ref:
As outlined above, you can use a ref to handle the empty additionalProperties object and providing it a description.
Skip additionalProperties:
Omitting additionalProperties altogether would resolve the issue, but since we are using TypeSpec, we need the type to align for the examples. Additionally, this wouldn't be 100% accurate to the API.
Fix in the generator:
Ideally, a fix for the doc generator should account for this.
Steps to Reproduce
Test schema:
openapi: 3.0.0info:
title: Bug Testdescription: Testing Bugversion: 0.0.0tags:
- name: Testpaths:
/with-bug:
post:
operationId: TestBug_createsummary: With Bugdescription: |- This is to test an `additionalProperties` bug.responses:
'201':
content:
application/json:
schema:
$ref: '#/components/schemas/ReturnType'requestBody:
required: truecontent:
application/json:
schema:
$ref: '#/components/schemas/WithBug'components:
schemas:
ReturnType:
type: objectrequired: [test1, test2]properties:
test1:
type: stringenum: [Yes]test2:
type: stringenum: [Test]WithBug:
type: objectrequired: [with_bug, workaround, workaround_with_bug, additional_props_without_bug]properties:
with_bug:
type: objectadditionalProperties: {}description: Bug with additionalPropertiesworkaround:
allOf:
- $ref: '#/components/schemas/WorkAroundModel'description: Workaroundworkaround_with_bug:
$ref: '#/components/schemas/WorkAroundModel'additional_props_without_bug:
type: objectadditionalProperties:
type: objectproperties:
test3:
type: stringenum: [Additional Prop Test]description: Test with additional propsWorkAroundModel:
type: objectadditionalProperties: {}description: Workaround
Generate documentation from this schema.
Observe the duplicated descriptions.
Screenshots
Additional Context
Does not seem to render the duplicate description in a SWAGGER editor/viewer.
Environment
Version: 3.0.2 & 4.0.1
The text was updated successfully, but these errors were encountered:
Describe the Bug
When a property is defined as an object with
additionalProperties
and no properties are defined, the description is duplicated at both the top-level object and theadditionalProperties
level.This does not occur in the following scenarios:
additionalProperties
.Example workaround:
And the ref:
This workaround forces the object to render without a
additionalProperties
(property name*), though it’s not ideal. We cannot omitadditionalProperties
due to the need for valid examples in TypeSpec.additionalProperties
contains valid properties, the duplication does not occur.Expected Behavior
The description should not be duplicated. The
additionalProperties
section should either stay empty or have a preset description explaining that the property name is user-defined.Current Behavior
The top-level object description is duplicated at the
additionalProperties
level whenadditionalProperties
is empty.Possible Solutions
Create a separate
ref
:ref
to handle the emptyadditionalProperties
object and providing it a description.Skip
additionalProperties
:additionalProperties
altogether would resolve the issue, but since we are using TypeSpec, we need the type to align for the examples. Additionally, this wouldn't be 100% accurate to the API.Fix in the generator:
Steps to Reproduce
Test schema:
Screenshots
Additional Context
Does not seem to render the duplicate description in a SWAGGER editor/viewer.
Environment
The text was updated successfully, but these errors were encountered: