@inditextech/swagger-ui-plugin-diff-highlight 0.3.1-SNAPSHOT.188.1 → 0.3.1-SNAPSHOT.192.1
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.
- package/README.md +29 -15
- package/dist/diff.css +10 -0
- package/dist/index.js +51 -12
- package/dist/index.mjs +51 -12
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -24,6 +24,8 @@ When an API evolves from one version to the next, it is hard to see _what actual
|
|
|
24
24
|
| `deleted` | red + strikethrough |
|
|
25
25
|
| `updated` | inline `old → new` (old in red strikethrough, new in green) |
|
|
26
26
|
|
|
27
|
+
An updated schema keeps Swagger UI's native model, including its name, body, toggle and nested marks. The changed keywords are listed at the end of its accordion body.
|
|
28
|
+
|
|
27
29
|
## Getting Started
|
|
28
30
|
|
|
29
31
|
### Installation
|
|
@@ -62,7 +64,7 @@ Then feed it an annotated spec. Anything without an annotation renders normally.
|
|
|
62
64
|
|
|
63
65
|
#### Annotating your OpenAPI document
|
|
64
66
|
|
|
65
|
-
Annotate any operation, parameter, response, or schema
|
|
67
|
+
Annotate any operation, parameter, response, or schema with `x-diff-status`:
|
|
66
68
|
|
|
67
69
|
```jsonc
|
|
68
70
|
// An added parameter
|
|
@@ -89,7 +91,7 @@ Annotate any operation, parameter, response, or schema property with `x-diff-sta
|
|
|
89
91
|
}
|
|
90
92
|
```
|
|
91
93
|
|
|
92
|
-
For an **updated** schema
|
|
94
|
+
For an **updated** schema, also provide the before/after sub-schemas so the plugin can render `old → new`. Any schema works, including composed ones (`allOf`, `anyOf`, `oneOf`) and root schemas under `components/schemas`:
|
|
93
95
|
|
|
94
96
|
```jsonc
|
|
95
97
|
"timeout": {
|
|
@@ -104,13 +106,25 @@ Valid `x-diff-status` values: `added`, `deleted`, `updated`, `unchanged` (or sim
|
|
|
104
106
|
|
|
105
107
|
##### Where each key goes
|
|
106
108
|
|
|
107
|
-
| Extension | Where it lives
|
|
108
|
-
| ----------------- |
|
|
109
|
-
| `x-diff-status` | On an operation, a parameter object, a response object, or a schema
|
|
110
|
-
| `x-diff-original` | On a schema
|
|
111
|
-
| `x-diff-new` | On a schema
|
|
109
|
+
| Extension | Where it lives | Notes |
|
|
110
|
+
| ----------------- | ------------------------------------------------------------------- | ------------------------------------------------ |
|
|
111
|
+
| `x-diff-status` | On an operation, a parameter object, a response object, or a schema | Required on every element you want to mark |
|
|
112
|
+
| `x-diff-original` | On a schema, including a root or composed schema | Only with `"updated"`; the **before** sub-schema |
|
|
113
|
+
| `x-diff-new` | On a schema, including a root or composed schema | Only with `"updated"`; the **after** sub-schema |
|
|
114
|
+
|
|
115
|
+
All three keys are **sibling properties** of the element they annotate. `x-diff-original` / `x-diff-new` are only read for `"updated"` schemas. For added/deleted elements, `x-diff-status` alone is enough.
|
|
116
|
+
|
|
117
|
+
##### How an updated schema renders
|
|
118
|
+
|
|
119
|
+
The plugin compares the two snapshots keyword by keyword and lists each difference after the native body:
|
|
120
|
+
|
|
121
|
+
- A scalar keyword that changed shows `old → new`, for example `maxLength: 100 → 200`.
|
|
122
|
+
- A scalar keyword that appeared or disappeared shows its value in green or red. Values such as `0`, `false` and `null` count as values.
|
|
123
|
+
- `type` and `format` show as one row, for example `type: string → integer($int64)`.
|
|
124
|
+
- Object and array keywords (`properties`, `items`, `allOf`, `required` and so on) show a compact `changed` marker instead of a dump. Their added, deleted and updated children keep their own marks in the native body.
|
|
125
|
+
- Enum changes keep their dedicated view, and keyword changes are listed next to it.
|
|
112
126
|
|
|
113
|
-
|
|
127
|
+
The rows live inside the schema's accordion, so they appear only while it is open. Keyword summaries require both snapshots. Non-enum updates without them keep their native content and status mark without a comparison. Extensions (`x-*`) are ignored. Enum comparisons retain their existing renderer. Include an explicit `type` in both enum snapshots so their type and format labels are meaningful.
|
|
114
128
|
|
|
115
129
|
#### Generating the annotations automatically
|
|
116
130
|
|
|
@@ -118,11 +132,11 @@ You don't have to annotate by hand. Compute the diff between your **old** and **
|
|
|
118
132
|
|
|
119
133
|
Whatever tool you use, the change types map onto `x-diff-status` the same way:
|
|
120
134
|
|
|
121
|
-
| Diff-tool change type | `x-diff-status` | Extra keys
|
|
122
|
-
| --------------------------- | --------------- |
|
|
123
|
-
| added / new | `added` | –
|
|
124
|
-
| removed / deleted / missing | `deleted` | –
|
|
125
|
-
| changed / modified | `updated` | `x-diff-original`, `x-diff-new` (
|
|
135
|
+
| Diff-tool change type | `x-diff-status` | Extra keys |
|
|
136
|
+
| --------------------------- | --------------- | ----------------------------------------- |
|
|
137
|
+
| added / new | `added` | – |
|
|
138
|
+
| removed / deleted / missing | `deleted` | – |
|
|
139
|
+
| changed / modified | `updated` | `x-diff-original`, `x-diff-new` (schemas) |
|
|
126
140
|
|
|
127
141
|
The three examples below convert real output from popular tools into the same annotated spec.
|
|
128
142
|
|
|
@@ -215,7 +229,7 @@ Modified: GET /users/{id}
|
|
|
215
229
|
[Breaking] Body attribute modified: timeout
|
|
216
230
|
```
|
|
217
231
|
|
|
218
|
-
A modified attribute type maps to an `updated` schema
|
|
232
|
+
A modified attribute type maps to an `updated` schema. Supply the old and new types as sub-schemas:
|
|
219
233
|
|
|
220
234
|
```jsonc
|
|
221
235
|
"timeout": {
|
|
@@ -237,7 +251,7 @@ The plugin uses Swagger UI's [`wrapComponents`](https://swagger-ui.github.io/swa
|
|
|
237
251
|
| `operation` | An endpoint / opblock | The **unresolved** spec via `specSelectors`/`specPath` |
|
|
238
252
|
| `parameterRow` | A request parameter row | `props.param` / `props.rawParam` |
|
|
239
253
|
| `response` | A response row | `props.response` |
|
|
240
|
-
| `Model` | A schema
|
|
254
|
+
| `Model` | A schema | `props.schema` |
|
|
241
255
|
| `ModelCollapse` | A schema accordion that contains a change (`diff-ancestor`) | The enclosing `Model`'s schema, or the unresolved spec for root schemas |
|
|
242
256
|
|
|
243
257
|
Three implementation details worth knowing:
|
package/dist/diff.css
CHANGED
|
@@ -53,6 +53,16 @@
|
|
|
53
53
|
color: #6b6b6b;
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
+
/* Keyword changes of an updated schema, listed at the end of its accordion. */
|
|
57
|
+
.diff-schema-changes {
|
|
58
|
+
margin-top: 4px;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.diff-schema-changed {
|
|
62
|
+
color: #b9770e;
|
|
63
|
+
font-weight: 600;
|
|
64
|
+
}
|
|
65
|
+
|
|
56
66
|
/* Mark the schema property NAME cell, not just its value.
|
|
57
67
|
* The value cell (2nd <td>) carries the diff class; :has() lets us reach the
|
|
58
68
|
* sibling name cell (1st <td>) rendered by ObjectModel. The `> td >` scoping
|
package/dist/index.js
CHANGED
|
@@ -37,6 +37,7 @@ module.exports = __toCommonJS(index_exports);
|
|
|
37
37
|
// src/DiffHighlightPlugin.jsx
|
|
38
38
|
var import_react = __toESM(require("react"));
|
|
39
39
|
var EnumDiffContext = (0, import_react.createContext)(null);
|
|
40
|
+
var UpdateDetailsContext = (0, import_react.createContext)(null);
|
|
40
41
|
var enumValueKey = (value) => JSON.stringify(
|
|
41
42
|
value,
|
|
42
43
|
(_, item) => item && typeof item === "object" && !Array.isArray(item) ? Object.fromEntries(
|
|
@@ -102,6 +103,44 @@ var describeSchema = (schema) => {
|
|
|
102
103
|
}
|
|
103
104
|
return format ? `${type}($${format})` : type;
|
|
104
105
|
};
|
|
106
|
+
var UpdatedValue = ({ before, after }) => /* @__PURE__ */ import_react.default.createElement("span", { className: "diff-updated-inline" }, /* @__PURE__ */ import_react.default.createElement("span", { className: "diff-updated-old" }, before), /* @__PURE__ */ import_react.default.createElement("span", { className: "diff-updated-arrow" }, " \u2192 "), /* @__PURE__ */ import_react.default.createElement("span", { className: "diff-updated-new" }, after));
|
|
107
|
+
var plain = (value) => value != null && typeof value.toJS === "function" ? value.toJS() : value;
|
|
108
|
+
var isStructured = (value) => value != null && typeof value === "object";
|
|
109
|
+
var scalarText = (value) => typeof value === "string" ? value : JSON.stringify(value);
|
|
110
|
+
var typeLabel = (schema) => schema.get("type") ? describeSchema(schema) : void 0;
|
|
111
|
+
var changeValue = (before, after) => {
|
|
112
|
+
if (isStructured(before) || isStructured(after)) {
|
|
113
|
+
return /* @__PURE__ */ import_react.default.createElement("span", { className: "diff-schema-changed" }, "changed");
|
|
114
|
+
}
|
|
115
|
+
if (before === void 0) {
|
|
116
|
+
return /* @__PURE__ */ import_react.default.createElement("span", { className: "diff-added" }, scalarText(after));
|
|
117
|
+
}
|
|
118
|
+
if (after === void 0) {
|
|
119
|
+
return /* @__PURE__ */ import_react.default.createElement("span", { className: "diff-deleted" }, scalarText(before));
|
|
120
|
+
}
|
|
121
|
+
return /* @__PURE__ */ import_react.default.createElement(UpdatedValue, { before: scalarText(before), after: scalarText(after) });
|
|
122
|
+
};
|
|
123
|
+
var schemaUpdateDetails = (original, updated, enumHandled) => {
|
|
124
|
+
if (!isMapLike(original) || !isMapLike(updated)) {
|
|
125
|
+
return null;
|
|
126
|
+
}
|
|
127
|
+
const typed = !enumHandled && Boolean(typeLabel(original) || typeLabel(updated));
|
|
128
|
+
const skipped = (key) => key === "type" || key === "enum" || key === "$$ref" || key.startsWith("x-") || key === "format" && (typed || enumHandled);
|
|
129
|
+
const keys = /* @__PURE__ */ new Set([...original.keySeq(), ...updated.keySeq()]);
|
|
130
|
+
const entries = typed ? [["type", typeLabel(original), typeLabel(updated)]] : [];
|
|
131
|
+
for (const key of keys) {
|
|
132
|
+
if (!skipped(key)) {
|
|
133
|
+
entries.push([key, plain(original.get(key)), plain(updated.get(key))]);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
const rows = entries.filter(
|
|
137
|
+
([, before, after]) => enumValueKey(before) !== enumValueKey(after)
|
|
138
|
+
);
|
|
139
|
+
if (rows.length === 0) {
|
|
140
|
+
return null;
|
|
141
|
+
}
|
|
142
|
+
return /* @__PURE__ */ import_react.default.createElement("div", { className: "diff-schema-changes" }, rows.map(([key, before, after]) => /* @__PURE__ */ import_react.default.createElement("div", { className: "diff-schema-change", key }, /* @__PURE__ */ import_react.default.createElement("span", { className: "diff-schema-keyword" }, key), ":", " ", changeValue(before, after))));
|
|
143
|
+
};
|
|
105
144
|
var DiffHighlightPlugin = () => ({
|
|
106
145
|
wrapComponents: {
|
|
107
146
|
/**
|
|
@@ -121,20 +160,19 @@ var DiffHighlightPlugin = () => ({
|
|
|
121
160
|
() => enumChanged ? { original, updated, supplemental, getComponent } : null,
|
|
122
161
|
[enumChanged, original, updated, supplemental, getComponent]
|
|
123
162
|
);
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
}
|
|
163
|
+
const updateDetails = (0, import_react.useMemo)(
|
|
164
|
+
() => status === "updated" ? schemaUpdateDetails(original, updated, enumChanged) : null,
|
|
165
|
+
[status, original, updated, enumChanged]
|
|
166
|
+
);
|
|
129
167
|
const marked = containsChange(
|
|
130
168
|
rawSchema,
|
|
131
169
|
localRefResolver(specJsonOf(system))
|
|
132
170
|
);
|
|
171
|
+
let schema = rawSchema;
|
|
133
172
|
if (enumChanged) {
|
|
134
|
-
|
|
135
|
-
return /* @__PURE__ */ import_react.default.createElement(ContainsChangeContext.Provider, { value: marked }, /* @__PURE__ */ import_react.default.createElement(EnumDiffContext.Provider, { value: enumDiff }, /* @__PURE__ */ import_react.default.createElement(Original, { ...props, schema })));
|
|
173
|
+
schema = supplemental ? rawSchema.remove("enum").remove("x-diff-status").remove("x-diff-original").remove("x-diff-new") : rawSchema.set("enum", updatedEnum || originalEnum);
|
|
136
174
|
}
|
|
137
|
-
const model = /* @__PURE__ */ import_react.default.createElement(ContainsChangeContext.Provider, { value: marked }, /* @__PURE__ */ import_react.default.createElement(EnumDiffContext.Provider, { value:
|
|
175
|
+
const model = /* @__PURE__ */ import_react.default.createElement(ContainsChangeContext.Provider, { value: marked }, /* @__PURE__ */ import_react.default.createElement(UpdateDetailsContext.Provider, { value: updateDetails }, /* @__PURE__ */ import_react.default.createElement(EnumDiffContext.Provider, { value: enumDiff }, /* @__PURE__ */ import_react.default.createElement(Original, { ...props, schema }))));
|
|
138
176
|
if (status === "deleted" || status === "added") {
|
|
139
177
|
return /* @__PURE__ */ import_react.default.createElement("span", { className: `diff-${status}` }, model);
|
|
140
178
|
}
|
|
@@ -154,6 +192,7 @@ var DiffHighlightPlugin = () => ({
|
|
|
154
192
|
var _a;
|
|
155
193
|
const fromModel = (0, import_react.useContext)(ContainsChangeContext);
|
|
156
194
|
const diff = (0, import_react.useContext)(EnumDiffContext);
|
|
195
|
+
const details = (0, import_react.useContext)(UpdateDetailsContext);
|
|
157
196
|
const nestedDiff = (0, import_react.useMemo)(
|
|
158
197
|
() => diff && { ...diff, supplemental: false },
|
|
159
198
|
[diff]
|
|
@@ -164,11 +203,11 @@ var DiffHighlightPlugin = () => ({
|
|
|
164
203
|
localRefResolver(specJson)
|
|
165
204
|
);
|
|
166
205
|
const classes = marked ? [props.classes, "diff-ancestor"].filter(Boolean).join(" ") : props.classes;
|
|
167
|
-
if (!(diff == null ? void 0 : diff.supplemental)) {
|
|
206
|
+
if (!details && !(diff == null ? void 0 : diff.supplemental)) {
|
|
168
207
|
return /* @__PURE__ */ import_react.default.createElement(Original, { ...props, classes });
|
|
169
208
|
}
|
|
170
|
-
const EnumModel = diff.getComponent("EnumModel");
|
|
171
|
-
return /* @__PURE__ */ import_react.default.createElement(EnumDiffContext.Provider, { value: null }, /* @__PURE__ */ import_react.default.createElement(Original, { ...props, classes }, props.children, /* @__PURE__ */ import_react.default.createElement(EnumDiffContext.Provider, { value: nestedDiff }, /* @__PURE__ */ import_react.default.createElement(EnumModel, { getComponent: diff.getComponent }))));
|
|
209
|
+
const EnumModel = (diff == null ? void 0 : diff.supplemental) && diff.getComponent("EnumModel");
|
|
210
|
+
return /* @__PURE__ */ import_react.default.createElement(UpdateDetailsContext.Provider, { value: null }, /* @__PURE__ */ import_react.default.createElement(EnumDiffContext.Provider, { value: (diff == null ? void 0 : diff.supplemental) ? null : diff }, /* @__PURE__ */ import_react.default.createElement(Original, { ...props, classes }, props.children, details, EnumModel && /* @__PURE__ */ import_react.default.createElement(EnumDiffContext.Provider, { value: nestedDiff }, /* @__PURE__ */ import_react.default.createElement(EnumModel, { getComponent: diff.getComponent })))));
|
|
172
211
|
},
|
|
173
212
|
EnumModel: (Original) => function EnumModel(props) {
|
|
174
213
|
var _a, _b, _c, _d;
|
|
@@ -191,7 +230,7 @@ var DiffHighlightPlugin = () => ({
|
|
|
191
230
|
return void 0;
|
|
192
231
|
};
|
|
193
232
|
const ModelCollapse = props.getComponent("ModelCollapse");
|
|
194
|
-
return /* @__PURE__ */ import_react.default.createElement("span", { className: "prop-enum" }, /* @__PURE__ */ import_react.default.createElement("br", null), originalType !== updatedType && /* @__PURE__ */ import_react.default.createElement("div", { className: "diff-type-change" }, "Type:
|
|
233
|
+
return /* @__PURE__ */ import_react.default.createElement("span", { className: "prop-enum" }, /* @__PURE__ */ import_react.default.createElement("br", null), originalType !== updatedType && /* @__PURE__ */ import_react.default.createElement("div", { className: "diff-type-change" }, "Type: ", /* @__PURE__ */ import_react.default.createElement(UpdatedValue, { before: originalType, after: updatedType })), "Enum:", /* @__PURE__ */ import_react.default.createElement("br", null), /* @__PURE__ */ import_react.default.createElement(
|
|
195
234
|
ModelCollapse,
|
|
196
235
|
{
|
|
197
236
|
collapsedContent: /* @__PURE__ */ import_react.default.createElement("span", null, "Array [ ", values.length, " ]")
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// src/DiffHighlightPlugin.jsx
|
|
2
2
|
import React, { createContext, useContext, useMemo } from "react";
|
|
3
3
|
var EnumDiffContext = createContext(null);
|
|
4
|
+
var UpdateDetailsContext = createContext(null);
|
|
4
5
|
var enumValueKey = (value) => JSON.stringify(
|
|
5
6
|
value,
|
|
6
7
|
(_, item) => item && typeof item === "object" && !Array.isArray(item) ? Object.fromEntries(
|
|
@@ -66,6 +67,44 @@ var describeSchema = (schema) => {
|
|
|
66
67
|
}
|
|
67
68
|
return format ? `${type}($${format})` : type;
|
|
68
69
|
};
|
|
70
|
+
var UpdatedValue = ({ before, after }) => /* @__PURE__ */ React.createElement("span", { className: "diff-updated-inline" }, /* @__PURE__ */ React.createElement("span", { className: "diff-updated-old" }, before), /* @__PURE__ */ React.createElement("span", { className: "diff-updated-arrow" }, " \u2192 "), /* @__PURE__ */ React.createElement("span", { className: "diff-updated-new" }, after));
|
|
71
|
+
var plain = (value) => value != null && typeof value.toJS === "function" ? value.toJS() : value;
|
|
72
|
+
var isStructured = (value) => value != null && typeof value === "object";
|
|
73
|
+
var scalarText = (value) => typeof value === "string" ? value : JSON.stringify(value);
|
|
74
|
+
var typeLabel = (schema) => schema.get("type") ? describeSchema(schema) : void 0;
|
|
75
|
+
var changeValue = (before, after) => {
|
|
76
|
+
if (isStructured(before) || isStructured(after)) {
|
|
77
|
+
return /* @__PURE__ */ React.createElement("span", { className: "diff-schema-changed" }, "changed");
|
|
78
|
+
}
|
|
79
|
+
if (before === void 0) {
|
|
80
|
+
return /* @__PURE__ */ React.createElement("span", { className: "diff-added" }, scalarText(after));
|
|
81
|
+
}
|
|
82
|
+
if (after === void 0) {
|
|
83
|
+
return /* @__PURE__ */ React.createElement("span", { className: "diff-deleted" }, scalarText(before));
|
|
84
|
+
}
|
|
85
|
+
return /* @__PURE__ */ React.createElement(UpdatedValue, { before: scalarText(before), after: scalarText(after) });
|
|
86
|
+
};
|
|
87
|
+
var schemaUpdateDetails = (original, updated, enumHandled) => {
|
|
88
|
+
if (!isMapLike(original) || !isMapLike(updated)) {
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
const typed = !enumHandled && Boolean(typeLabel(original) || typeLabel(updated));
|
|
92
|
+
const skipped = (key) => key === "type" || key === "enum" || key === "$$ref" || key.startsWith("x-") || key === "format" && (typed || enumHandled);
|
|
93
|
+
const keys = /* @__PURE__ */ new Set([...original.keySeq(), ...updated.keySeq()]);
|
|
94
|
+
const entries = typed ? [["type", typeLabel(original), typeLabel(updated)]] : [];
|
|
95
|
+
for (const key of keys) {
|
|
96
|
+
if (!skipped(key)) {
|
|
97
|
+
entries.push([key, plain(original.get(key)), plain(updated.get(key))]);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
const rows = entries.filter(
|
|
101
|
+
([, before, after]) => enumValueKey(before) !== enumValueKey(after)
|
|
102
|
+
);
|
|
103
|
+
if (rows.length === 0) {
|
|
104
|
+
return null;
|
|
105
|
+
}
|
|
106
|
+
return /* @__PURE__ */ React.createElement("div", { className: "diff-schema-changes" }, rows.map(([key, before, after]) => /* @__PURE__ */ React.createElement("div", { className: "diff-schema-change", key }, /* @__PURE__ */ React.createElement("span", { className: "diff-schema-keyword" }, key), ":", " ", changeValue(before, after))));
|
|
107
|
+
};
|
|
69
108
|
var DiffHighlightPlugin = () => ({
|
|
70
109
|
wrapComponents: {
|
|
71
110
|
/**
|
|
@@ -85,20 +124,19 @@ var DiffHighlightPlugin = () => ({
|
|
|
85
124
|
() => enumChanged ? { original, updated, supplemental, getComponent } : null,
|
|
86
125
|
[enumChanged, original, updated, supplemental, getComponent]
|
|
87
126
|
);
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
}
|
|
127
|
+
const updateDetails = useMemo(
|
|
128
|
+
() => status === "updated" ? schemaUpdateDetails(original, updated, enumChanged) : null,
|
|
129
|
+
[status, original, updated, enumChanged]
|
|
130
|
+
);
|
|
93
131
|
const marked = containsChange(
|
|
94
132
|
rawSchema,
|
|
95
133
|
localRefResolver(specJsonOf(system))
|
|
96
134
|
);
|
|
135
|
+
let schema = rawSchema;
|
|
97
136
|
if (enumChanged) {
|
|
98
|
-
|
|
99
|
-
return /* @__PURE__ */ React.createElement(ContainsChangeContext.Provider, { value: marked }, /* @__PURE__ */ React.createElement(EnumDiffContext.Provider, { value: enumDiff }, /* @__PURE__ */ React.createElement(Original, { ...props, schema })));
|
|
137
|
+
schema = supplemental ? rawSchema.remove("enum").remove("x-diff-status").remove("x-diff-original").remove("x-diff-new") : rawSchema.set("enum", updatedEnum || originalEnum);
|
|
100
138
|
}
|
|
101
|
-
const model = /* @__PURE__ */ React.createElement(ContainsChangeContext.Provider, { value: marked }, /* @__PURE__ */ React.createElement(EnumDiffContext.Provider, { value:
|
|
139
|
+
const model = /* @__PURE__ */ React.createElement(ContainsChangeContext.Provider, { value: marked }, /* @__PURE__ */ React.createElement(UpdateDetailsContext.Provider, { value: updateDetails }, /* @__PURE__ */ React.createElement(EnumDiffContext.Provider, { value: enumDiff }, /* @__PURE__ */ React.createElement(Original, { ...props, schema }))));
|
|
102
140
|
if (status === "deleted" || status === "added") {
|
|
103
141
|
return /* @__PURE__ */ React.createElement("span", { className: `diff-${status}` }, model);
|
|
104
142
|
}
|
|
@@ -118,6 +156,7 @@ var DiffHighlightPlugin = () => ({
|
|
|
118
156
|
var _a;
|
|
119
157
|
const fromModel = useContext(ContainsChangeContext);
|
|
120
158
|
const diff = useContext(EnumDiffContext);
|
|
159
|
+
const details = useContext(UpdateDetailsContext);
|
|
121
160
|
const nestedDiff = useMemo(
|
|
122
161
|
() => diff && { ...diff, supplemental: false },
|
|
123
162
|
[diff]
|
|
@@ -128,11 +167,11 @@ var DiffHighlightPlugin = () => ({
|
|
|
128
167
|
localRefResolver(specJson)
|
|
129
168
|
);
|
|
130
169
|
const classes = marked ? [props.classes, "diff-ancestor"].filter(Boolean).join(" ") : props.classes;
|
|
131
|
-
if (!(diff == null ? void 0 : diff.supplemental)) {
|
|
170
|
+
if (!details && !(diff == null ? void 0 : diff.supplemental)) {
|
|
132
171
|
return /* @__PURE__ */ React.createElement(Original, { ...props, classes });
|
|
133
172
|
}
|
|
134
|
-
const EnumModel = diff.getComponent("EnumModel");
|
|
135
|
-
return /* @__PURE__ */ React.createElement(EnumDiffContext.Provider, { value: null }, /* @__PURE__ */ React.createElement(Original, { ...props, classes }, props.children, /* @__PURE__ */ React.createElement(EnumDiffContext.Provider, { value: nestedDiff }, /* @__PURE__ */ React.createElement(EnumModel, { getComponent: diff.getComponent }))));
|
|
173
|
+
const EnumModel = (diff == null ? void 0 : diff.supplemental) && diff.getComponent("EnumModel");
|
|
174
|
+
return /* @__PURE__ */ React.createElement(UpdateDetailsContext.Provider, { value: null }, /* @__PURE__ */ React.createElement(EnumDiffContext.Provider, { value: (diff == null ? void 0 : diff.supplemental) ? null : diff }, /* @__PURE__ */ React.createElement(Original, { ...props, classes }, props.children, details, EnumModel && /* @__PURE__ */ React.createElement(EnumDiffContext.Provider, { value: nestedDiff }, /* @__PURE__ */ React.createElement(EnumModel, { getComponent: diff.getComponent })))));
|
|
136
175
|
},
|
|
137
176
|
EnumModel: (Original) => function EnumModel(props) {
|
|
138
177
|
var _a, _b, _c, _d;
|
|
@@ -155,7 +194,7 @@ var DiffHighlightPlugin = () => ({
|
|
|
155
194
|
return void 0;
|
|
156
195
|
};
|
|
157
196
|
const ModelCollapse = props.getComponent("ModelCollapse");
|
|
158
|
-
return /* @__PURE__ */ React.createElement("span", { className: "prop-enum" }, /* @__PURE__ */ React.createElement("br", null), originalType !== updatedType && /* @__PURE__ */ React.createElement("div", { className: "diff-type-change" }, "Type:
|
|
197
|
+
return /* @__PURE__ */ React.createElement("span", { className: "prop-enum" }, /* @__PURE__ */ React.createElement("br", null), originalType !== updatedType && /* @__PURE__ */ React.createElement("div", { className: "diff-type-change" }, "Type: ", /* @__PURE__ */ React.createElement(UpdatedValue, { before: originalType, after: updatedType })), "Enum:", /* @__PURE__ */ React.createElement("br", null), /* @__PURE__ */ React.createElement(
|
|
159
198
|
ModelCollapse,
|
|
160
199
|
{
|
|
161
200
|
collapsedContent: /* @__PURE__ */ React.createElement("span", null, "Array [ ", values.length, " ]")
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inditextech/swagger-ui-plugin-diff-highlight",
|
|
3
|
-
"version": "0.3.1-SNAPSHOT.
|
|
3
|
+
"version": "0.3.1-SNAPSHOT.192.1",
|
|
4
4
|
"description": "Highlight API changes (added/updated/deleted) inline in swagger-ui-react via a custom diff-highlighting plugin.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"swagger",
|