Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: script to validate embedded examples in the asyncapi.md file #1059

Merged

Conversation

AnimeshKumar923
Copy link
Contributor

@AnimeshKumar923 AnimeshKumar923 commented Jun 7, 2024

Description

  • This PR adds a script and CI (will added after the script has been finalized) to validate the embedded examples in the asyncapi.md file

Remaining tasks:

  • Script enhancement (achieved through d78f639 --> finalized through 8c0e78c)
  • Add a CI file integrating the script (achieved through 46f32a5 --> finalized through aa1564f)

Related issue(s):
Resolves #957

Changes:

- copied files from test branch: https://github.com/AnimeshKumar923/asyncapi-spec/tree/embedded-examples-jsonPath-test/scripts/validation

- copied because merge conflict and older files in the previous branch
- files required for validation of embedded examples
- still a WIP, more modification and refinement will be made in future
mistakenly added this file
Changes:

- added comments in the file as suggested by Sergio here: asyncapi#957 (comment)
- more comments to be adjusted according to the json format
@AnimeshKumar923
Copy link
Contributor Author

AnimeshKumar923 commented Jun 8, 2024

Current State of the script

This is what the script currently does as of 915f808:

  • This initial script replaces the section in the ex-base-doc.json by extracting the json section by taking the comment given in this format <!-- asyncapi-example-tester:{"test":"Info Object","json_path":"$.info"} -->.

    • Here test is the object which stores the name of the example (will change the name of object later on for better naming convention achieved through 150f3f5)
    • json_path is the object specifying the location where the example should be replaced.

Future objective:

  • Update asyncapi.md file with more improved comments (achieved through 4529772)
  • Integrate the script with CLI validation (achieved through d78f639)
  • Add a YAML file for the CI (achieved through 46f32a5 --> finalized through e1c8798)

Changes:

- modified the script so that it can handle component object example
- the script as of now add the fields and sub-fields in the updated-doc
  so that the other references remain unaffected
- the earlier version was removinga and adding the whole part of the
  document altogether which affected the references and dependencies in
  the entire document
@aeworxet
Copy link

@asyncapi/bounty_team

@asyncapi-bot asyncapi-bot added the bounty AsyncAPI Bounty label Jun 10, 2024
Changes:

- updated the spec file to correctly match the json format and for
  further parsing
- updated the base document to support more of the examples
- added missing json version for some of the examples
spec/asyncapi.md Outdated Show resolved Hide resolved
spec/asyncapi.md Outdated Show resolved Hide resolved
spec/asyncapi.md Outdated Show resolved Hide resolved
@AnimeshKumar923
Copy link
Contributor Author

/au

Changes:

- created new base doc removing additional fields under
  'securitySchemes'. This is because we have to individuallly validate
  each examples under the Security Scheme Object. The additional fields
  were giving error during validation of those examples.
- changes the object's name from `test` to `name`.
- updated the script according to the changed object's name
Changes:

- update script to determine the base doc, whether the 'server scheme
  object' is present or not
- updated both the base docs with more missing fields
Changes:

- modified script which now creates an array of extracted examples along
  with the metadatas of it
Changes:

- updated the script to make new documents for each examples
  in the asyncapi.md, and then store them into a new file for
  further vaidation process
- remove an extra character in asyncapi.md
spec/asyncapi.md Show resolved Hide resolved
spec/asyncapi.md Show resolved Hide resolved
Changes:
- trying to maintain the consistency of the single quotes
  and double quotes
Changes:
- the heading was mistakenly deleted during the addition of comments in
  the spec file
Changes:
- applied suggestion from: asyncapi#1059 (comment)
- applied suggestion from: asyncapi#1059 (comment)
Changes:
- modify yaml example which was failing due to not properly formatted
  structure
- update json pointer at one location
Changes:
- The json pointer library doesn't supports the URI representation,
  so to reduce the extra work this change was made
AnimeshKumar923 and others added 2 commits July 6, 2024 00:16
apply suggestion: asyncapi#1059 (comment)

Co-authored-by: Sergio Moya <1083296+smoya@users.noreply.github.com>
Changes:
- adjust script according to suggestion: asyncapi#1059 (comment)
@AnimeshKumar923 AnimeshKumar923 requested a review from smoya July 5, 2024 18:51
Copy link
Member

@smoya smoya left a comment

Choose a reason for hiding this comment

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

LGTM!

@smoya
Copy link
Member

smoya commented Jul 5, 2024

/rtm

@asyncapi-bot asyncapi-bot merged commit 62d3625 into asyncapi:master Jul 5, 2024
8 checks passed
@AnimeshKumar923
Copy link
Contributor Author

AnimeshKumar923 commented Jul 6, 2024

Some tasks remaining (out of bounty scope)
#1059 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Completed
Development

Successfully merging this pull request may close these issues.

Add a script and CI job to validate spec examples
4 participants