You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
constoasNormalizer=newOASNormalize(url)constvalidatedSchema=awaitoasNormalizer.validate()constschema=newOas(validatedSchema);awaitschema.dereference()// skipping some traverse logicletreqBodySchema: MediaTypeObject['schema']=undefinedif(reqBodySchema){if('type'inreqBodySchema){console.log('type:',reqBodySchema.type)}elseif('$ref'inreqBodySchema){// we should not need to do this because the schema has been dereferencedconsole.log('ref:',reqBodySchema.$ref)}}
At this point, since the schema has been dereferenced, should we narrow the types so we don't have to do type narrowing? Something like this:
// dereferencedSchema returns a narrower type of schema that removes RefObject from `X | RefObject`constdereferencedSchema=awaitschema.dereference()
Also, is there a way conditionally dereference schema? Something like this:
if('$ref'inreqBodySchema){constref=reqBodySchema.$ref// ref is a stringconstrefSchema1=schema.getReference(ref)// return schema or throw errorconstrefSchema2=schema.findReference(ref)// return schema or undefined}
Let me know if I am doing anything that is not standard. New to this (great) library. Also recommendations for great Typescript libraries for the OpenAPI / JSONSchema ecosystem would be greatly appreciated!
The text was updated successfully, but these errors were encountered:
This is tricky because technically after dereferencing $ref may still be present if there was a circular reference present. I'm definitely not opposed to adding some getReference and findReference tooling into oas core. If you're interested in doing that work we'd happily pull it in.
My current logic looks like this
At this point, since the schema has been dereferenced, should we narrow the types so we don't have to do type narrowing? Something like this:
Also, is there a way conditionally dereference schema? Something like this:
Let me know if I am doing anything that is not standard. New to this (great) library. Also recommendations for great Typescript libraries for the OpenAPI / JSONSchema ecosystem would be greatly appreciated!
The text was updated successfully, but these errors were encountered: