A Blazor WebAssembly app that converts Swagger / OpenAPI definitions to JavaScript object declarations.
https://stefh.github.io/SwaggerToJavaScriptObject/
- Input โ Paste your Swagger 2.0 or OpenAPI 3.0 JSON document into the text area.
- Analyze โ Click Analyze to extract all type definitions (
definitionsin Swagger 2.0 orcomponents.schemasin OpenAPI 3.0). - Select types โ A list of checkboxes lets you select or deselect the types you want to generate. Use Select All / Deselect All for convenience.
- Generate โ Click Generate to bundle and dereference the selected types and produce JavaScript
constdeclarations, e.g.:
const petSchema = {
"type": "object",
"required": [
"name",
"photoUrls"
],
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"category": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"name": {
"type": "string"
}
},
"xml": {
"name": "Category"
}
},
"name": {
"type": "string",
"example": "doggie"
},
"photoUrls": {
"type": "array",
"xml": {
"wrapped": true
},
"items": {
"type": "string",
"xml": {
"name": "photoUrl"
}
}
},
"tags": {
"type": "array",
"xml": {
"wrapped": true
},
"items": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"name": {
"type": "string"
}
},
"xml": {
"name": "Tag"
}
}
},
"status": {
"type": "string",
"description": "pet status in the store",
"enum": [
"available",
"pending",
"sold"
]
}
},
"xml": {
"name": "Pet"
}
};- Copy to clipboard โ Copy the generated JavaScript with one click.
- Blazor WebAssembly (.NET 10)
- Bootstrap 5 for styling
- Hosted on GitHub Pages
dotnet run --project src/SwaggerToJavaScriptObject/SwaggerToJavaScriptObject.csprojThen open http://localhost:5000.