@atolis-hq/corum 0.1.9 → 0.1.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -86,7 +86,6 @@ export function mapDocument(document, entry, packConfig) {
|
|
|
86
86
|
endpointNode.properties = {
|
|
87
87
|
method: method.toUpperCase(),
|
|
88
88
|
path: urlPath,
|
|
89
|
-
...(operation.operationId && { operationId: operation.operationId }),
|
|
90
89
|
...(operation.summary && { description: operation.summary }),
|
|
91
90
|
};
|
|
92
91
|
nodes.push(endpointNode);
|
|
@@ -94,16 +93,23 @@ export function mapDocument(document, entry, packConfig) {
|
|
|
94
93
|
if (requestBody?.content) {
|
|
95
94
|
const jsonContent = requestBody.content['application/json'];
|
|
96
95
|
if (jsonContent?.schema) {
|
|
97
|
-
emitSchemaNode(jsonContent.schema, `${operationId}-request`, endpointId, 'schemas', packConfig, entry.spec, nodes, edges, diagnostics, sharedSchemas);
|
|
96
|
+
const ref = emitSchemaNode(jsonContent.schema, `${operationId}-request`, endpointId, 'schemas', packConfig, entry.spec, nodes, edges, diagnostics, sharedSchemas);
|
|
97
|
+
if (ref)
|
|
98
|
+
endpointNode.properties.request = ref;
|
|
98
99
|
}
|
|
99
100
|
}
|
|
101
|
+
const responses = {};
|
|
100
102
|
for (const [status, response] of Object.entries(operation.responses ?? {})) {
|
|
101
103
|
const responseObj = response;
|
|
102
104
|
const jsonContent = responseObj.content?.['application/json'];
|
|
103
105
|
if (jsonContent?.schema) {
|
|
104
|
-
emitSchemaNode(jsonContent.schema, `${operationId}-response-${status}`, endpointId, 'schemas', packConfig, entry.spec, nodes, edges, diagnostics, sharedSchemas);
|
|
106
|
+
const ref = emitSchemaNode(jsonContent.schema, `${operationId}-response-${status}`, endpointId, 'schemas', packConfig, entry.spec, nodes, edges, diagnostics, sharedSchemas);
|
|
107
|
+
if (ref)
|
|
108
|
+
responses[status] = ref;
|
|
105
109
|
}
|
|
106
110
|
}
|
|
111
|
+
if (Object.keys(responses).length > 0)
|
|
112
|
+
endpointNode.properties.responses = responses;
|
|
107
113
|
}
|
|
108
114
|
}
|
|
109
115
|
return { nodes, edges, diagnostics };
|
|
@@ -125,13 +131,7 @@ function makeNode(template, component, specPath, id) {
|
|
|
125
131
|
}
|
|
126
132
|
function emitSchemaNode(schema, name, parentId, section, packConfig, specPath, nodes, edges, diagnostics, sharedSchemas) {
|
|
127
133
|
if (isRefSchema(schema)) {
|
|
128
|
-
|
|
129
|
-
if (refId) {
|
|
130
|
-
const parent = nodes.find(n => n.id === parentId);
|
|
131
|
-
if (parent)
|
|
132
|
-
parent.properties[`${section}.${name}`] = refId;
|
|
133
|
-
}
|
|
134
|
-
return;
|
|
134
|
+
return sharedSchemas.get(refName(schema.$ref));
|
|
135
135
|
}
|
|
136
136
|
const schemaId = deriveNodeId('schema', undefined, name, parentId, section);
|
|
137
137
|
const [component] = parentId.split('.');
|
|
@@ -139,6 +139,7 @@ function emitSchemaNode(schema, name, parentId, section, packConfig, specPath, n
|
|
|
139
139
|
nodes.push(node);
|
|
140
140
|
edges.push({ id: `${parentId}__has-field__${schemaId}`, from: parentId, to: schemaId, type: 'has-field', state: 'implemented', stability: 'unstable' });
|
|
141
141
|
emitFields(schema, schemaId, 'fields', packConfig, specPath, nodes, edges, diagnostics, sharedSchemas);
|
|
142
|
+
return `#/${section}/${name}`;
|
|
142
143
|
}
|
|
143
144
|
function emitFields(schema, parentId, section, packConfig, specPath, nodes, edges, diagnostics, sharedSchemas) {
|
|
144
145
|
for (const [fieldName, fieldSchema] of Object.entries(schema.properties ?? {})) {
|