Multiple bug fixes with proper attribute inheritance#661
Merged
n0tl3ss merged 2 commits intomicronaut-projects:masterfrom Feb 23, 2022
Merged
Multiple bug fixes with proper attribute inheritance#661n0tl3ss merged 2 commits intomicronaut-projects:masterfrom
n0tl3ss merged 2 commits intomicronaut-projects:masterfrom
Conversation
graemerocher
approved these changes
Feb 10, 2022
|
@n0tl3ss I just tested your fix with Micronaut 3.3.4 and Micronaut OpenAPI 4.0.1 Snapshot. A lot of our issues were fixed. A big thank you! I found one issue regarding the nullability of a type. The new generated code looks like this (Attributes like protocol can be null when email sending is disabled): ReadEmailOutputLocationDto:
required:
- protocol
type: object
properties:
protocol:
allOf:
- $ref: '#/components/schemas/EmailSendProtocolDto'
- description: Protocol used for the connection
description: Schema that represents an existing email output location
ReadEmailSettingsDto:
required:
- active
- hostname
- plaintextPassword
- port
- protocol
- senderEmail
- username
type: object
properties:
active:
type: boolean
description: "Flag that indicates whether the email sending is active or\
\ not. If set to false, all other values are null"
hostname:
type: string
description: Hostname or IP of the email server or null if email sending
is disabled
nullable: true
port:
type: integer
description: Port of the email server or null if email sending is disabled
format: int32
nullable: true
protocol:
allOf:
- $ref: '#/components/schemas/EmailSendProtocolDto'
- description: Protocol used for the connection or null if email sending
is disabled
nullable: true
username:
type: string
description: Email username to login or null if email sending is disabled
nullable: true
plaintextPassword:
type: string
description: Plaintext password for the email user to login in or null if
email sending is disabled
nullable: true
senderEmail:
type: string
description: Sender email address that is used to send emails or null if
email sending is disabled
nullable: true
description: Schema that represents the current email settingsProblematic is the location of the nullable: ReadEmailSettingsDto:
required:
SNIPPED
type: object
properties:
SNIPPED OTHER PROPERTIES
protocol:
allOf:
- $ref: '#/components/schemas/EmailSendProtocolDto'
- description: Protocol used for the connection or null if email sending
is disabled
nullable: true <------------------------------------- Should not be down hereAccording to https://stackoverflow.com/questions/40920441/how-to-specify-a-property-can-be-null-or-a-reference-with-swagger the null should be at before the allOf, so like this: ReadEmailSettingsDto:
required:
SNIPPED
type: object
properties:
SNIPPED OTHER PROPERTIES
protocol:
nullable: true <------------------------------------- Moved up here
allOf:
- $ref: '#/components/schemas/EmailSendProtocolDto'
- description: Protocol used for the connection or null if email sending
is disabledMoving all nullable=true used in combination with allOf in our code fixes the OpenAPI generation. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This code change fixes issue with inheritance of "description" and "nullable" attributes. The fields annotated with
@Schemashould always consider their "description" and "nullable" arguments. The "required" argument should be only displayed in the list of the required properties of the DTO.Fix #659