Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 18
Reference Resolution
References currently only work for "internal" as in, within the components section of the document. However any AsyncApiSchema (and by extension JsonSchema) type, can have a reference to the components section.
The default reference resolutions can be seen in the table below
| Action | Default |
|---|---|
| Writing | DoNotInlineReferences |
| Reading | ResolveReferences |
Making an object model that contains references will yield those references written to yaml/json by default Looking something like
channels:
mychannel:
publish:
message:
payload:
type: objectrequired:
- testBproperties:
testC:
$ref: '#/components/schemas/testC'testB:
$ref: '#/components/schemas/testB'components:
schemas:
testD:
type: stringformat: uuidtestC:
type: objectproperties:
testD:
$ref: '#/components/schemas/testD'testB:
type: booleandescription: testSetting InlineReferences to true, will yield a document looking like the following
channels:
mychannel:
publish:
message:
payload:
type: objectrequired:
- testBproperties:
testC:
type: objectproperties:
testD:
type: stringformat: uuidtestB:
type: booleandescription: testcomponents: { }Notice that all of the references are in-lined, and removed from the components section, as they are not needed anymore.
You can set the ReferenceResolution mode by using custom (non-default) AsyncApiWriterSettings and setting the ReferenceInline property according to your needs.
Note that the default is DoNotInlineReferences.
varoutputString=newStringWriter(CultureInfo.InvariantCulture);varwriter=newAsyncApiYamlWriter(outputString,newAsyncApiWriterSettings{ReferenceInline=ReferenceInlineSetting.InlineReferences});asyncApiDocument.SerializeV2(writer);You can set the ReferenceResolution mode by using custom (non-default) AsyncApiReaderSettings and setting the ReferenceResolution property according to your needs.
Note that the default is ResolveReferences.
varreader=newAsyncApiStringReader(newAsyncApiReaderSettings{ReferenceResolution=ReferenceResolutionSetting.DoNotResolveReferences});