Skip to content

Commit 402c017

Browse files
Fix missing method result type in generated documentation
* fix: Missing method result type in generated documentation * feat: Add section template for callback params
1 parent 790f26e commit 402c017

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2+
| Param | Type | Required | Description |
3+
| ---------------------- | -------------------- | ------------------------ | ----------------------- |

src/macrofier/engine.mjs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -157,14 +157,14 @@ const getLinkForSchema = (schema, json) => {
157157
const copySchemasIntoModules = config.copySchemasIntoModules
158158
const definitions = json.definitions || json.components.schemas
159159

160-
const type = Types.getSchemaType(schema, json, { templateDir: state.typeTemplateDir, namespace: !config.copySchemasIntoModules })
160+
const type = Types.getSchemaType(schema, json, { templateDir: state.typeTemplateDir, namespace: false })
161161

162162
// local - insert a bogus link, that we'll update later based on final table-of-contents
163-
if (definitions && definitions[type]) {
163+
if (json.components.schemas[type]) {
164164
return `#\$\{LINK:schema:${type}\}`
165165
}
166166
else {
167-
const [group, schema] = Object.entries(definitions).find(([key, value]) => definitions[key] && definitions[key][type]) || [null, null]
167+
const [group, schema] = Object.entries(json['x-schemas']).find(([key, value]) => json['x-schemas'][key] && json['x-schemas'][key][type]) || [null, null]
168168
if (group && schema) {
169169
if (copySchemasIntoModules) {
170170
return `#\$\{LINK:schema:${type}\}`
@@ -1543,6 +1543,7 @@ function insertMethodMacros(template, methodObj, platformApi, appApi, templates,
15431543
method.transform = getTemplate('/codeblocks/transform', templates).replace(/\$\{transforms\}/g, JSON.stringify(method.transforms))
15441544
}
15451545

1546+
15461547
const paramDelimiter = config.operators ? config.operators.paramDelimiter : ''
15471548

15481549
const temporalItemName = isTemporalSetMethod(methodObj) ? methodObj.result.schema.items && methodObj.result.schema.items.title || 'Item' : ''
@@ -1632,7 +1633,7 @@ function insertMethodMacros(template, methodObj, platformApi, appApi, templates,
16321633
// If there's a notifier for this method, and it has examples, use its params for the eventParams section
16331634
if (eventForSubscriber && eventForSubscriber.examples && eventForSubscriber.examples.length) {
16341635
eventParams = (eventForSubscriber.params && eventForSubscriber.params.length) ?
1635-
getTemplate('/sections/parameters', templates) + eventForSubscriber.params.map(p => insertParameterMacros(getTemplate('/parameters/default', templates), p, eventForSubscriber, appApi)).join('')
1636+
getTemplate('/sections/callback-parameters', templates) + eventForSubscriber.params.map(p => insertParameterMacros(getTemplate('/parameters/default', templates), p, eventForSubscriber, appApi)).join('')
16361637
: ''
16371638
}
16381639
}
@@ -2063,7 +2064,7 @@ function insertExampleMacros(template, examples, method, json, templates, appApi
20632064

20642065
function generateResult(result, json, templates, { name = '' } = {}) {
20652066

2066-
const type = Types.getSchemaType(result, json, { templateDir: state.typeTemplateDir, namespace: !config.copySchemasIntoModules })
2067+
const type = Types.getSchemaType(result, json, { templateDir: state.typeTemplateDir, namespace: false })
20672068

20682069
if (result.type === 'object' && result.properties) {
20692070
let content = getTemplate('/types/object', templates).split('\n')
@@ -2084,13 +2085,13 @@ function generateResult(result, json, templates, { name = '' } = {}) {
20842085

20852086
// if we get a real link use it
20862087
if (link !== '#') {
2087-
return `[${Types.getSchemaType(result, json, { templateDir: state.typeTemplateDir, namespace: !config.copySchemasIntoModules })}](${link})`
2088+
return `[${Types.getSchemaType(result, json, { templateDir: state.typeTemplateDir, namespace: false })}](${link})`
20882089
}
20892090
// otherwise this was a schema with no title, and we'll just copy it here
20902091
else {
20912092
const schema = localizeDependencies(result, json)
20922093
return getTemplate('/types/default', templates)
2093-
.replace(/\$\{type\}/, Types.getSchemaShape(schema, json, { templateDir: state.typeTemplateDir, namespace: !config.copySchemasIntoModules }))
2094+
.replace(/\$\{type\}/, Types.getSchemaShape(schema, json, { templateDir: state.typeTemplateDir, namespace: false }))
20942095
}
20952096
}
20962097
else {

0 commit comments

Comments
 (0)