Title: Should SerializeV2WithoutReference resolve in object references as well? · LEGO/AsyncAPI.NET · Discussion #93 · GitHub
Open Graph Title: Should SerializeV2WithoutReference resolve in object references as well? · LEGO/AsyncAPI.NET · Discussion #93
X Title: Should SerializeV2WithoutReference resolve in object references as well? · LEGO/AsyncAPI.NET · Discussion #93
Description: Should SerializeV2WithoutReference resolve in object references as well?
Open Graph Description: Hi, SerializeV2WithoutReference currently only resolves top-level reference & uses internally SerializeV2 for properties of the AsyncApiSchema. In my use-case I am trying to extract payload schema ...
X Description: Hi, SerializeV2WithoutReference currently only resolves top-level reference & uses internally SerializeV2 for properties of the AsyncApiSchema. In my use-case I am trying to extract payload sch...
Opengraph URL: https://github.com/LEGO/AsyncAPI.NET/discussions/93
X: @github
Domain: patch-diff.githubusercontent.com
{"@context":"https://schema.org","@type":"QAPage","mainEntity":{"@type":"Question","name":"Should SerializeV2WithoutReference resolve in object references as well?","text":"Hi,
\nSerializeV2WithoutReference currently only resolves top-level reference & uses internally SerializeV2 for properties of the AsyncApiSchema.
\nIn my use-case I am trying to extract payload schema to validate my de-serialized model in test against schema with JsonSchema package.
\nIn my tests I serialize and de-serialize my model, parse AsyncApi schema with this library and extract payload with SerializeV2WithoutReference.
\nThat results in JSON like this:
\n{\n \"type\": \"object\",\n \"required\": [\n \"testA\",\n ],\n \"properties\": {\n \"testA\": {\n \"type\": \"string\",\n \"format\": \"uuid\"\n },\n \"testB\": {\n \"$ref\": \"#/components/schemas/testB\"\n }\n }\n}\n
\ntestB is still unresolved so I would need to jump through hoops to actually use this JsonSchema to validate my serialized JSON.
\nIs there any reason to not serialize completely without references, or some way to do that?
\nBonus questions, could this library go step further than just parsing AsyncApi schema and allow validation capacity same as JsonSchema does?
","upvoteCount":1,"answerCount":1,"acceptedAnswer":{"@type":"Answer","text":"Ive spent a bit more time on the issue, trying to streamline this a bit for the payload schemas.
\nAnyway.. I will make a PR that fixes this.
\nWith default settings you will get an output like this
\nchannels:\n mychannel:\n publish:\n message:\n payload:\n type: object\n required:\n - testB\n properties:\n testC:\n $ref: '#/components/schemas/testC'\n testB:\n $ref: '#/components/schemas/testB'\ncomponents:\n schemas:\n testD:\n type: string\n format: uuid\n testC:\n type: object\n properties:\n testD:\n $ref: '#/components/schemas/testD'\n testB:\n type: boolean\n description: test
\nBut if you instead use the inlinereferences setting
\nlike so
\nvar outputString = new StringWriter(CultureInfo.InvariantCulture);\nvar writer = new AsyncApiYamlWriter(outputString, new AsyncApiWriterSettings { ReferenceInline = ReferenceInlineSetting.InlineReferences });\nasyncApiDocument.SerializeV2(writer);
\nyou will get an output like the following
\nchannels:\n mychannel:\n publish:\n message:\n payload:\n type: object\n required:\n - testB\n properties:\n testC:\n type: object\n properties:\n testD:\n type: string\n format: uuid\n testB:\n type: boolean\n description: test\ncomponents: { }
","upvoteCount":1,"url":"https://github.com/LEGO/AsyncAPI.NET/discussions/93#discussioncomment-5074289"}}}
| route-pattern | /_view_fragments/Voltron::DiscussionsFragmentsController/show/:user_id/:repository/:discussion_number/discussion_layout(.:format) |
| route-controller | voltron_discussions_fragments |
| route-action | discussion_layout |
| fetch-nonce | v2:4fea8092-5bd9-5d22-1fd3-1682934b4f31 |
| current-catalog-service-hash | 9f0abe34da433c9b6db74bffa2466494a717b579a96b30a5d252e5090baea7be |
| request-id | 8400:315857:354C31:4A6C4B:6982151A |
| html-safe-nonce | 2cce8ba7ea33165ba410951b1c87f6e7eca266fa9a761ce47e70f5ad8d100398 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4NDAwOjMxNTg1NzozNTRDMzE6NEE2QzRCOjY5ODIxNTFBIiwidmlzaXRvcl9pZCI6IjY2ODA5OTY3NTI0NDU5ODU1NCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | cfe7fad56479e2d67e0f8e94baecd7ac8edc2064940601c174e273c1ac0cf74f |
| hovercard-subject-tag | discussion:4881222 |
| github-keyboard-shortcuts | repository,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/Voltron::DiscussionsFragmentsController/show/LEGO/AsyncAPI.NET/93/discussion_layout |
| twitter:image | https://opengraph.githubassets.com/681490ed6e56d36e418729b938c8bed75aceec0ebc0a891cf2cc6d2c697fa78c/LEGO/AsyncAPI.NET/discussions/93 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/681490ed6e56d36e418729b938c8bed75aceec0ebc0a891cf2cc6d2c697fa78c/LEGO/AsyncAPI.NET/discussions/93 |
| og:image:alt | Hi, SerializeV2WithoutReference currently only resolves top-level reference & uses internally SerializeV2 for properties of the AsyncApiSchema. In my use-case I am trying to extract payload schema ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | c5d01132ac10b0b45b88f4c1c8790502d669eb065ff383dc5e4757c174f3380f |
| turbo-cache-control | no-preview |
| go-import | github.com/LEGO/AsyncAPI.NET git https://github.com/LEGO/AsyncAPI.NET.git |
| octolytics-dimension-user_id | 4530164 |
| octolytics-dimension-user_login | LEGO |
| octolytics-dimension-repository_id | 442113220 |
| octolytics-dimension-repository_nwo | LEGO/AsyncAPI.NET |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 442113220 |
| octolytics-dimension-repository_network_root_nwo | LEGO/AsyncAPI.NET |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 0ac87bbde7c9f04b7ead5505c12f56048d89df09 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width