mirror of
https://github.com/ritz078/transform.git
synced 2026-11-20 16:22:53 +03:00
Fix 500 for json schema to openapi schema (#268)
* Use same package in packageUrl, view, package.json Trying a hunch for https://github.com/ritz078/transform/issues/247 Either way, I don't know how these relate but it seems like they should all be the same. I also can't find any other reference to the wework package. * Move OpenAPI conversion to api
This commit is contained in:
1 parent
707f15f6f2
commit
c0867beff1
3 files changed
+28
-11
No files matched your search
@@ -0,0 +1,15 @@
|
||||
import { NextApiRequest, NextApiResponse } from "next";
|
||||
import toOpenApi from "@openapi-contrib/json-schema-to-openapi-schema";
|
||||
|
||||
export default async (req: NextApiRequest, res: NextApiResponse) => {
|
||||
try {
|
||||
const jsonSchema = req.body;
|
||||
const openApiSchema = await toOpenApi(JSON.parse(jsonSchema), {
|
||||
cloneSchema: true
|
||||
});
|
||||
|
||||
res.status(200).send(JSON.stringify(openApiSchema, null, 2));
|
||||
} catch (e) {
|
||||
res.status(500).send(e.message);
|
||||
}
|
||||
};
|
||||
@@ -1,18 +1,12 @@
|
||||
import ConversionPanel, { Transformer } from "@components/ConversionPanel";
|
||||
import * as React from "react";
|
||||
import { useCallback } from "react";
|
||||
import toOpenApi from "@openapi-contrib/json-schema-to-openapi-schema";
|
||||
import request from "@utils/request";
|
||||
import { Alert } from "evergreen-ui";
|
||||
|
||||
export default function() {
|
||||
const transformer = useCallback<Transformer>(
|
||||
async ({ value }) =>
|
||||
JSON.stringify(
|
||||
toOpenApi(JSON.parse(value), {
|
||||
cloneSchema: true
|
||||
}),
|
||||
null,
|
||||
2
|
||||
),
|
||||
const transformer = useCallback(
|
||||
({ value }) => request("/api/json-schema-to-openapi-schema", value),
|
||||
[]
|
||||
);
|
||||
|
||||
@@ -24,6 +18,14 @@ export default function() {
|
||||
editorDefaultValue="jsonSchema"
|
||||
resultTitle="Open API Schema"
|
||||
resultLanguage={"json"}
|
||||
resultEditorProps={{
|
||||
topNotifications: () => (
|
||||
<Alert
|
||||
backgroundColor="#e7f7ff"
|
||||
title="This code is converted on the server."
|
||||
/>
|
||||
)
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
+1
-1
@@ -151,7 +151,7 @@ export const categorizedRoutes = [
|
||||
label: "to OpenAPI Schema",
|
||||
path: "json-schema-to-openapi-schema",
|
||||
packageName: "json-schema-to-openapi-schema",
|
||||
packageUrl: "https://github.com/wework/json-schema-to-openapi-schema"
|
||||
packageUrl: "https://github.com/openapi-contrib/json-schema-to-openapi-schema"
|
||||
},
|
||||
{
|
||||
label: "to Protobuf",
|
||||
|
||||
Reference in new issue
Block a user