zudoku 0.3.0-dev.122 → 0.3.0-dev.124

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.
@@ -1,5 +1,5 @@
1
1
  import "./jsx-runtime-B6kdoens.js";
2
- import { o as l } from "./index-YcqHGXdv.js";
2
+ import { o as l } from "./index-Bx0AgZT5.js";
3
3
  import "./urql-DrBfkb92.js";
4
4
  import "./ZudokuContext-BIZ8zHbZ.js";
5
5
  import "zudoku/openapi-worker";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zudoku",
3
- "version": "0.3.0-dev.122",
3
+ "version": "0.3.0-dev.124",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist",
@@ -109,25 +109,31 @@ export const Sidecar = ({
109
109
 
110
110
  const requestBodyContent = operation.requestBody?.content;
111
111
 
112
- const path = operation.path.split("/").map((part, i, arr) => (
113
- // eslint-disable-next-line react/no-array-index-key
114
- <Fragment key={part + i}>
115
- {part.startsWith("{") && part.endsWith("}") ? (
116
- <ColorizedParam
117
- name={part.slice(1, -1)}
118
- backgroundOpacity="0"
119
- // same as in `ParameterListItem`
120
- slug={operation.slug + "-" + part.slice(1, -1).toLocaleLowerCase()}
121
- >
122
- {part}
123
- </ColorizedParam>
124
- ) : (
125
- part
126
- )}
127
- {i < arr.length - 1 ? "/" : null}
128
- <wbr />
129
- </Fragment>
130
- ));
112
+ const path = operation.path.split("/").map((part, i, arr) => {
113
+ const isParam =
114
+ (part.startsWith("{") && part.endsWith("}")) || part.startsWith(":");
115
+ const paramName = isParam ? part.replace(/[:{}]/g, "") : undefined;
116
+
117
+ return (
118
+ // eslint-disable-next-line react/no-array-index-key
119
+ <Fragment key={part + i}>
120
+ {paramName ? (
121
+ <ColorizedParam
122
+ name={paramName}
123
+ backgroundOpacity="0"
124
+ // same as in `ParameterListItem`
125
+ slug={`${operation.slug}-${paramName.toLocaleLowerCase()}`}
126
+ >
127
+ {part}
128
+ </ColorizedParam>
129
+ ) : (
130
+ part
131
+ )}
132
+ {i < arr.length - 1 ? "/" : null}
133
+ <wbr />
134
+ </Fragment>
135
+ );
136
+ });
131
137
 
132
138
  const code = useMemo(() => {
133
139
  const example = requestBodyContent?.[0]?.schema
@@ -164,8 +164,9 @@ export const Playground = ({
164
164
  });
165
165
 
166
166
  const path = url.split("/").map((part, i, arr) => {
167
- const isPathParam = part.startsWith("{") && part.endsWith("}");
168
- const replaced = part.replace(/[{}]/g, "");
167
+ const isPathParam =
168
+ (part.startsWith("{") && part.endsWith("}")) || part.startsWith(":");
169
+ const replaced = part.replace(/[:{}]/g, "");
169
170
  const value = formState.pathParams.find((p) => p.name === replaced)?.value;
170
171
 
171
172
  const pathParamValue = value ? (
@@ -191,10 +192,6 @@ export const Playground = ({
191
192
  );
192
193
  });
193
194
 
194
- const lang = mimeTypeToLanguage(
195
- queryMutation.data?.headers.get("Content-Type") ?? "",
196
- );
197
-
198
195
  const headerEntries = Array.from(queryMutation.data?.headers.entries() ?? []);
199
196
 
200
197
  const urlQueryParams = formState.queryParams
@@ -1,11 +1,12 @@
1
1
  import type { PlaygroundForm } from "./Playground.js";
2
2
 
3
3
  export const createUrl = (host: string, path: string, data: PlaygroundForm) => {
4
- const filledPath = path.replace(
5
- /\{(\w+)}/g,
6
- (_, key) =>
7
- data.pathParams.find((part) => part.name === key)?.value || `{${key}}`,
8
- );
4
+ const filledPath = path.replace(/(:\w+|\{\w+})/g, (match) => {
5
+ const key = match.replace(/[:{}]/g, "");
6
+ const value = data.pathParams.find((part) => part.name === key)?.value;
7
+
8
+ return value ?? match;
9
+ });
9
10
 
10
11
  const url = new URL(filledPath, host);
11
12