Skip to content

[BAC-640] Move $ref in allOf for Entities when nullable - #21

Merged
taleh007 merged 1 commit into
masterfrom
feature/BAC-640
Dec 4, 2025
Merged

[BAC-640] Move $ref in allOf for Entities when nullable#21
taleh007 merged 1 commit into
masterfrom
feature/BAC-640

Conversation

@taleh007

@taleh007 taleh007 commented Dec 4, 2025

Copy link
Copy Markdown
Contributor

it will help to generate proper schema

Current json schema cannot be used to generate nullable reference in sdk:

class HistoryEntry < APIEntity
  attribute :answer, :entity, class_name: 'Ask::Messages::Answer'
  attribute :answers, :array, of: 'Ask::Messages::Answer'

  validates :answer, presence: { allow_nil: true }
  validates :answers, presence: { allow_nil: true }
end

swagger (3.0.1)=>

HistoryEntry:
    type: object
    required:
    - answer
    - answers
    properties:
    answer:
        "$ref": "#/components/schemas/Ask.Messages.Answer"
        nullable: true
    answers:
        items:
        - "$ref": "#/components/schemas/Ask.Messages.Answer"
        type: array
        nullable: true

openapi-ts =>

export type HistoryEntry = {
    answer: AskMessagesAnswer;
    answers: Array<AskMessagesAnswer> | null;
};

it should be:

export type HistoryEntry = {
    answer: AskMessagesAnswer | null;
    answers: Array<AskMessagesAnswer> | null;
};

@taleh007
taleh007 requested review from HolyWalley and yard December 4, 2025 11:25
it will help to generate proper schema
@taleh007
taleh007 merged commit 78e7a7f into master Dec 4, 2025
1 check 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