-
-
Notifications
You must be signed in to change notification settings - Fork 415
feat: add jsonld schema support #1375
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
base: main
Are you sure you want to change the base?
Conversation
🦋 Changeset detectedLatest commit: 33086d2 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
This comment was marked as outdated.
This comment was marked as outdated.
6de32e5
to
2c0e0b7
Compare
This comment was marked as outdated.
This comment was marked as outdated.
@codex review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Codex Review: Here are some suggestions.
swagger-typescript-api/src/schema-parser/schema-formatters.ts
Lines 17 to 49 in 33086d2
this.templatesWorker = schemaParser.templatesWorker; | |
} | |
base = { | |
[SCHEMA_TYPES.ENUM]: (parsedSchema) => { | |
if (this.config.generateUnionEnums) { | |
return { | |
...parsedSchema, | |
$content: parsedSchema.content, | |
content: this.config.Ts.UnionType( | |
parsedSchema.content.map(({ value }) => value), | |
), | |
}; | |
} | |
return { | |
...parsedSchema, | |
$content: parsedSchema.content, | |
content: this.config.Ts.EnumFieldsWrapper(parsedSchema.content), | |
}; | |
}, | |
[SCHEMA_TYPES.OBJECT]: (parsedSchema) => { | |
if (parsedSchema.nullable) | |
return this.inline[SCHEMA_TYPES.OBJECT](parsedSchema); | |
return { | |
...parsedSchema, | |
$content: parsedSchema.content, | |
content: this.formatObjectContent(parsedSchema.content), | |
}; | |
}, | |
[SCHEMA_TYPES.PRIMITIVE]: (parsedSchema) => { | |
return { | |
...parsedSchema, |
[P1] Add formatter branches for JSON-LD schema types
The commit introduces three new schema types (JSONLD_CONTEXT
, JSONLD_ENTITY
, JSONLD_TYPE
), but SchemaFormatters
still formats only enums, objects and primitives. When a JSON-LD schema is parsed, formatSchema
falls through and returns the raw array of field descriptors. Templates render that array with JavaScript’s default stringification (e.g. [object Object]
) so the generated interfaces don’t contain any of the actual properties. This can be seen in the new snapshots where every field prints [object Object]
. The formatter needs explicit entries (or reuse the object formatter) for the JSON-LD schema types to emit valid TypeScript.
swagger-typescript-api/src/code-gen-process.ts
Lines 420 to 463 in 33086d2
)), | |
); | |
} | |
if (generateClient) { | |
const apiModuleContent = this.templatesWorker.renderTemplate( | |
templatesToRender.api, | |
{ | |
...configuration, | |
route, | |
}, | |
); | |
modularApiFileInfos.push( | |
...(await this.createOutputFileInfo( | |
configuration, | |
pascalCase(route.moduleName), | |
apiModuleContent, | |
)), | |
); | |
} | |
} | |
} | |
return [ | |
...(await this.createOutputFileInfo( | |
configuration, | |
fileNames.dataContracts, | |
this.templatesWorker.renderTemplate( | |
templatesToRender.dataContracts, | |
configuration, | |
), | |
)), | |
...(generateClient | |
? await this.createOutputFileInfo( | |
configuration, | |
fileNames.httpClient, | |
this.templatesWorker.renderTemplate( | |
templatesToRender.httpClient, | |
configuration, | |
), | |
) | |
: []), | |
...modularApiFileInfos, |
[P2] Render JSON-LD templates when generating data contracts
Configuration now declares jsonldContextDataContract
, jsonldEntityDataContract
, and jsonldUtils
templates, but the generation pipeline never renders them. CodeGenProcess.createModularFileInfo
and createSingleFileInfo
still only render templatesToRender.dataContracts
, routeTypes
, httpClient
, and api
; nothing consults jsonLdOptions.generateContext
/generateUtils
. As a result the new templates and options have no effect—no JSON-LD specific interfaces or utilities are emitted regardless of configuration. Hooking these templates into the output (e.g. when JSON-LD schemas are present) is required for the feature to work.
Reply with @codex fix comments
to fix any unresolved comments.
About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you open a pull request for review, mark a draft as ready, or comment "@codex review". If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex fix this CI failure" or "@codex address that feedback".
No description provided.