Skip to content

feat!: add schema union support - #785

Closed
jonaslagoni wants to merge 7 commits into
asyncapi:next-major-specfrom
jonaslagoni:schema_union_support
Closed

jonaslagoni wants to merge 7 commits into
asyncapi:next-major-specfrom
jonaslagoni:schema_union_support

Conversation

@jonaslagoni

@jonaslagoni jonaslagoni commented Jun 13, 2023 •

Copy link
Copy Markdown
Member

Description
This PR adds support for schema union support.

Related issue(s)
Related to asyncapi/spec#622
Fixes #809

@magicmatatjahu

magicmatatjahu commented Jun 13, 2023 •

Copy link
Copy Markdown
Member

@jonaslagoni You shouldn't remove the schemaFormat() method from message object, why? In v2 people still can use that, so they should have possibility to retrieve that value. In v3 we should have still that method, but retrieving logic should be based on the message.payload.schemaFormat value :)

EDIT: Ok, you removed from message trait - but if there's a possibility to have that value in v2 message's trait, the v2 should return that, in v3 we should return undefined.

Comment thread src/models/message-trait.ts Resolved
@jonaslagoni
jonaslagoni marked this pull request as ready for review June 16, 2023 11:08

@fmvilas fmvilas left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me in general. Left a minor comment.

Comment thread src/models/v3/message.ts
Comment on lines +28 to +29
const payloadIsSchemaUnion = this._json.payload.schemaFormat !== undefined;
return payloadIsSchemaUnion ? this._json.payload.schemaFormat : getDefaultSchemaFormat(this._meta.asyncapi.semver.version);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const payloadIsSchemaUnion = this._json.payload.schemaFormat !== undefined;
return payloadIsSchemaUnion ? this._json.payload.schemaFormat : getDefaultSchemaFormat(this._meta.asyncapi.semver.version);
const payloadIsSchemaUnion = this._json.payload?.schemaFormat !== undefined;
return payloadIsSchemaUnion ? this._json.payload.schemaFormat : getDefaultSchemaFormat(this._meta.asyncapi.semver.version);

I think payload can be undefined, right? We should be careful then.

Comment thread src/models/v2/message-trait.ts Resolved
Comment thread src/spec-types/v3.ts
schema: AsyncAPISchemaObject | ReferenceObject | any;
}

export type AllSchemaObjects = MultiFormatSchemaObject | AsyncAPISchemaObject | ReferenceObject | any;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@smoya smoya left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks pretty good to me! Just few changes that are needed. Including the one @fmvilas requested in https://github.com/asyncapi/parser-js/pull/785/files#r1242462994

@smoya

smoya commented Jul 17, 2023

Copy link
Copy Markdown
Member

I'm taking over this one as @jonaslagoni is 🌴 🏖️

@smoya

smoya commented Jul 18, 2023

Copy link
Copy Markdown
Member

Required Parser-API changes are now in the following PR asyncapi/parser-api#100

cc @jonaslagoni @fmvilas

@sonarqubecloud

Copy link
Copy Markdown

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@smoya

smoya commented Jul 24, 2023

Copy link
Copy Markdown
Member

Since this PR has been opened for a while and lot of changes come from next-major-spec, and because I took over the work, I'm gonna close this one and instead open a new PR whenever I have a first working version.

cc @jonaslagoni

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.

4 participants