-
Notifications
You must be signed in to change notification settings - Fork 1
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
When there is a allOf, the $ref are never resolved #2
Comments
@joepjoosten Tracked it down to this FIXME:
export const generateModule = (schemaId: string, schema: OpenApiSchema): string => {
const generationContext: SchemaGenContext = {
schemas: {}, // FIXME
hooks: {},
isSchemaIdBefore(_schemaId: OpenApiSchemaId) { return true; },
}; For the default one-file-per-schema it doesn't yet have enough context here to resolve references to other schemas. However, I went though the opensearch API you posted, and got it working with the single bundle mode, with a few fixes in this PR (tagged as v0.7.1): You'd need to pass in the following spec using the export default {
generationMethod: { method: 'bundled', bundleName: 'opensearch' },
hooks: {},
runtime: {},
modules: {},
}; The output is: https://gist.github.com/mkrause/b85e025d1fc1b5dd2bd2f4b522af2dae There's still a number of type errors in the resulting bundle however, which are due to recursive schema references. You can add manual type annotations for these in the spec, like in the example in the README here. |
Adding a whole bunch of manual type declarations is obviously not very convenient, and I'm considering adding some TypeScript type generation for the schemas that have recursive references. Unfortunately it's not always straightforward to find the right type to fix a recursive type reference, hence why it's a manual step currently. But it should be possible to automate most cases. |
I'm parsing the spec for opensearch (https://github.com/opensearch-project/opensearch-api-specification/releases/download/main-latest/opensearch-openapi.yaml)
To download it, and transform it to json:
When there is an allOf which has a $ref, it always fails because it can't find the schema.
Error:
Looks like the
isObjectSchema
function inGraphAnalyzer.ts
is always emptyThe text was updated successfully, but these errors were encountered: