Skip to content

feat(ls): add AsyncAPI 3 validation for compatible keywords#5096

Merged
glowcloud merged 20 commits intomainfrom
feat/async-3-compatible-validation
Jan 27, 2026
Merged

feat(ls): add AsyncAPI 3 validation for compatible keywords#5096
glowcloud merged 20 commits intomainfrom
feat/async-3-compatible-validation

Conversation

@glowcloud
Copy link
Contributor

@glowcloud glowcloud commented Jan 13, 2026

This PR:

  • adds AsyncAPI 3 validation for keywords compatible with AsyncAPI 2
  • adds targetSpecs to every validation rule to apply them to select AsyncAPI versions
  • adjusts names of rules that now apply to AsyncAPI 3 as well or ones that apply only to AsyncAPI 2 (e.g. additional-items--type-openapi-3-1--asyncapi-2 => additional-items--type-openapi-3-1--asyncapi-2--3, allowed-fields => allowed-fields-2-0--2-6). This does not apply for rules that are specific to keywords that exist only in AsyncAPI 2 (e.g. operationId field in Operation Object exists only in AsyncAPI 2, so the rule operation-id--type was not renamed).
  • fixes some bugs (e.g. incorrect linting messages, rules not being applied as they were not imported into the main file)

NOTE 1: There are cases where the allowed fields are technically the same (e.g. Tag Object and External Documentation Object), but it is now possible to reference these objects. As such, it seems to me that the allowed fields rule needs to be extended to include $ref as well, which is why I made it, and the rules for required fields, specific to AsyncAPI 2. If that is not what should happen, I will include Async3 in the targetSpecs as well.

NOTE 2: Similar to the cases above, Channel Object can be referenced, but it no longer has the $ref field like the Channel Item Object in AsyncAPI 2. This allowed the $ref to have siblings, which is not possible otherwise when the object is referenced. As such, I ported over the existing rule ($refValidLint) and added one which disallows siblings when $ref exists ($refNoSiblingsLint). If that's not valid, I'll remove these rules.

NOTE 3: For now I chose not to add targetSpecs to any binding, as I noted in #5095 (comment) that I think they are meant to work with any spec. If that's not the case, let me know and I'll try to go through each of them and check if targetSpecs should be specific to 2.0.x or 3.0.0, or if it should apply to both of them. Some of them are also outdated as noted in #5095 (comment) - I think it needs to be handled separately => I created a separate task for this.

TODO:

  • common/schema
  • bindings
  • tests
    • Security Scheme
    • Parameters - fix parameters object rules not applying to Async 3 and correct tests
    • Parameter
    • Operation Trait
    • Operation Bindings
    • Operation
    • Oauth Flows
    • Oauth Flow
    • Message Trait
    • Message Example
    • Message Bindings
    • Message
    • License
    • Info
    • External Documentation
    • Correlation ID
    • Contact
  • fix server variable type rule in Server Object - if a server variable has $ref, this error is shown: "variables' values must be of Server Variable Object shape" - this happens for both Async 2 and Async 3 - addressed in fix(ns-asyncapi-2): add missing reference metadata to server variables #5098
  • verify rules
  • adjust names (e.g. additional-items--type-openapi-3-1--asyncapi-2 => additional-items--type-openapi-3-1--asyncapi-2--3, allowed-fields => allowed-fields-2-0--2-6)

@glowcloud glowcloud self-assigned this Jan 13, 2026
@glowcloud glowcloud added enhancement New feature or request AsyncAPI 3.x labels Jan 13, 2026
@glowcloud glowcloud force-pushed the feat/async-3-compatible-validation branch from 391bc33 to 515fa34 Compare January 16, 2026 12:47
@glowcloud glowcloud marked this pull request as ready for review January 16, 2026 12:50
Base automatically changed from feat/OSS-254/251-add-config-and-docs-for-asyncapi3-with-compatible-properties to main January 23, 2026 07:34
@glowcloud glowcloud force-pushed the feat/async-3-compatible-validation branch from 515fa34 to e061ec6 Compare January 26, 2026 08:40
@glowcloud glowcloud merged commit f8cfb73 into main Jan 27, 2026
9 checks passed
@glowcloud glowcloud deleted the feat/async-3-compatible-validation branch January 27, 2026 12:02
robert-hebel-sb added a commit that referenced this pull request Jan 30, 2026
Add comprehensive lint validation rules for AsyncAPI 3.0.0 new and updated keywords following patterns from PR #5096.

Root level:
- operations field type validation

Operation Object:
- action (required) type and required field validation with quickFix
- channel (required) type and required field validation with quickFix
- title type validation
- reply type validation
- messages type validation (updated stub)

Parameter Object:
- enum type validation (array)
- default type validation
- examples type validation (array)

Components Object:
- operations values type validation

Operations Object (root operations):
- values type validation for operation objects map

Messages Object:
- values type validation for message objects map

Server Object:
- externalDocs type validation

Info Object:
- externalDocs type validation (updated stub)

Error codes added to codes.ts:
- ASYNCAPI3_ASYNC_API_FIELD_OPERATIONS_TYPE
- ASYNCAPI3_OPERATION section (2080000-2080500)
- ASYNCAPI3_SERVER section (2090000-2090500)
- ASYNCAPI3_INFO section (2100000-2100200)
- ASYNCAPI3_COMPONENTS section (2110000-2110100)
- ASYNCAPI3_PARAMETER section (2120000-2120300)
- ASYNCAPI3_OPERATIONS section (2130000-2130100)
- ASYNCAPI3_MESSAGES section (2140000-2140100)

All lint rules include appropriate error codes, validation messages, linter functions, and target AsyncAPI 3.0.0 specification.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
robert-hebel-sb added a commit that referenced this pull request Feb 3, 2026
Add comprehensive lint validation rules for AsyncAPI 3.0.0 new and updated keywords following
patterns from PR #5096.

Root level:
- operations field type validation

Operation Object:
- action (required) type and required field validation with quickFix
- channel (required) type and required field validation with quickFix
- title type validation
- reply type validation
- messages type validation (updated stub)

Parameter Object:
- enum type validation (array)
- default type validation
- examples type validation (array)

Components Object:
- operations values type validation

Operations Object (root operations):
- values type validation for operation objects map

Messages Object:
- values type validation for message objects map

Server Object:
- externalDocs type validation

Info Object:
- externalDocs type validation (updated stub)

Error codes added to codes.ts:
- ASYNCAPI3_ASYNC_API_FIELD_OPERATIONS_TYPE
- ASYNCAPI3_OPERATION section (2080000-2080500)
- ASYNCAPI3_SERVER section (2090000-2090500)
- ASYNCAPI3_INFO section (2100000-2100200)
- ASYNCAPI3_COMPONENTS section (2110000-2110100)
- ASYNCAPI3_PARAMETER section (2120000-2120300)
- ASYNCAPI3_OPERATIONS section (2130000-2130100)
- ASYNCAPI3_MESSAGES section (2140000-2140100)

All lint rules include appropriate error codes, validation messages, linter functions, and target
AsyncAPI 3.0.0 specification.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AsyncAPI 3.x enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants