raffel 0.1.2
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 +485 -0
- package/dist/adapters/grpc.d.ts +56 -0
- package/dist/adapters/grpc.d.ts.map +1 -0
- package/dist/adapters/grpc.int.test.d.ts +5 -0
- package/dist/adapters/grpc.int.test.d.ts.map +1 -0
- package/dist/adapters/grpc.int.test.js +168 -0
- package/dist/adapters/grpc.int.test.js.map +1 -0
- package/dist/adapters/grpc.js +434 -0
- package/dist/adapters/grpc.js.map +1 -0
- package/dist/adapters/http.d.ts +62 -0
- package/dist/adapters/http.d.ts.map +1 -0
- package/dist/adapters/http.int.test.d.ts +5 -0
- package/dist/adapters/http.int.test.d.ts.map +1 -0
- package/dist/adapters/http.int.test.js +396 -0
- package/dist/adapters/http.int.test.js.map +1 -0
- package/dist/adapters/http.js +606 -0
- package/dist/adapters/http.js.map +1 -0
- package/dist/adapters/index.d.ts +13 -0
- package/dist/adapters/index.d.ts.map +1 -0
- package/dist/adapters/index.js +13 -0
- package/dist/adapters/index.js.map +1 -0
- package/dist/adapters/jsonrpc.d.ts +86 -0
- package/dist/adapters/jsonrpc.d.ts.map +1 -0
- package/dist/adapters/jsonrpc.int.test.d.ts +5 -0
- package/dist/adapters/jsonrpc.int.test.d.ts.map +1 -0
- package/dist/adapters/jsonrpc.int.test.js +640 -0
- package/dist/adapters/jsonrpc.int.test.js.map +1 -0
- package/dist/adapters/jsonrpc.js +338 -0
- package/dist/adapters/jsonrpc.js.map +1 -0
- package/dist/adapters/s3db/adapter.d.ts +105 -0
- package/dist/adapters/s3db/adapter.d.ts.map +1 -0
- package/dist/adapters/s3db/adapter.js +539 -0
- package/dist/adapters/s3db/adapter.js.map +1 -0
- package/dist/adapters/s3db/index.d.ts +20 -0
- package/dist/adapters/s3db/index.d.ts.map +1 -0
- package/dist/adapters/s3db/index.js +25 -0
- package/dist/adapters/s3db/index.js.map +1 -0
- package/dist/adapters/s3db/s3db.int.test.d.ts +5 -0
- package/dist/adapters/s3db/s3db.int.test.d.ts.map +1 -0
- package/dist/adapters/s3db/s3db.int.test.js +472 -0
- package/dist/adapters/s3db/s3db.int.test.js.map +1 -0
- package/dist/adapters/s3db/types.d.ts +277 -0
- package/dist/adapters/s3db/types.d.ts.map +1 -0
- package/dist/adapters/s3db/types.js +7 -0
- package/dist/adapters/s3db/types.js.map +1 -0
- package/dist/adapters/s3db/utils/etag.d.ts +65 -0
- package/dist/adapters/s3db/utils/etag.d.ts.map +1 -0
- package/dist/adapters/s3db/utils/etag.js +99 -0
- package/dist/adapters/s3db/utils/etag.js.map +1 -0
- package/dist/adapters/s3db/utils/guards.d.ts +121 -0
- package/dist/adapters/s3db/utils/guards.d.ts.map +1 -0
- package/dist/adapters/s3db/utils/guards.js +169 -0
- package/dist/adapters/s3db/utils/guards.js.map +1 -0
- package/dist/adapters/s3db/utils/index.d.ts +9 -0
- package/dist/adapters/s3db/utils/index.d.ts.map +1 -0
- package/dist/adapters/s3db/utils/index.js +10 -0
- package/dist/adapters/s3db/utils/index.js.map +1 -0
- package/dist/adapters/s3db/utils/populate.d.ts +89 -0
- package/dist/adapters/s3db/utils/populate.d.ts.map +1 -0
- package/dist/adapters/s3db/utils/populate.js +165 -0
- package/dist/adapters/s3db/utils/populate.js.map +1 -0
- package/dist/adapters/tcp.d.ts +59 -0
- package/dist/adapters/tcp.d.ts.map +1 -0
- package/dist/adapters/tcp.int.test.d.ts +5 -0
- package/dist/adapters/tcp.int.test.d.ts.map +1 -0
- package/dist/adapters/tcp.int.test.js +379 -0
- package/dist/adapters/tcp.int.test.js.map +1 -0
- package/dist/adapters/tcp.js +400 -0
- package/dist/adapters/tcp.js.map +1 -0
- package/dist/adapters/websocket.d.ts +75 -0
- package/dist/adapters/websocket.d.ts.map +1 -0
- package/dist/adapters/websocket.int.test.d.ts +5 -0
- package/dist/adapters/websocket.int.test.d.ts.map +1 -0
- package/dist/adapters/websocket.int.test.js +383 -0
- package/dist/adapters/websocket.int.test.js.map +1 -0
- package/dist/adapters/websocket.js +393 -0
- package/dist/adapters/websocket.js.map +1 -0
- package/dist/cache/drivers/file.d.ts +77 -0
- package/dist/cache/drivers/file.d.ts.map +1 -0
- package/dist/cache/drivers/file.js +329 -0
- package/dist/cache/drivers/file.js.map +1 -0
- package/dist/cache/drivers/index.d.ts +10 -0
- package/dist/cache/drivers/index.d.ts.map +1 -0
- package/dist/cache/drivers/index.js +10 -0
- package/dist/cache/drivers/index.js.map +1 -0
- package/dist/cache/drivers/memory.d.ts +138 -0
- package/dist/cache/drivers/memory.d.ts.map +1 -0
- package/dist/cache/drivers/memory.int.test.d.ts +5 -0
- package/dist/cache/drivers/memory.int.test.d.ts.map +1 -0
- package/dist/cache/drivers/memory.int.test.js +241 -0
- package/dist/cache/drivers/memory.int.test.js.map +1 -0
- package/dist/cache/drivers/memory.js +659 -0
- package/dist/cache/drivers/memory.js.map +1 -0
- package/dist/cache/drivers/redis.d.ts +84 -0
- package/dist/cache/drivers/redis.d.ts.map +1 -0
- package/dist/cache/drivers/redis.js +243 -0
- package/dist/cache/drivers/redis.js.map +1 -0
- package/dist/cache/drivers/s3db.d.ts +78 -0
- package/dist/cache/drivers/s3db.d.ts.map +1 -0
- package/dist/cache/drivers/s3db.js +216 -0
- package/dist/cache/drivers/s3db.js.map +1 -0
- package/dist/cache/factory.d.ts +77 -0
- package/dist/cache/factory.d.ts.map +1 -0
- package/dist/cache/factory.js +130 -0
- package/dist/cache/factory.js.map +1 -0
- package/dist/cache/index.d.ts +62 -0
- package/dist/cache/index.d.ts.map +1 -0
- package/dist/cache/index.js +63 -0
- package/dist/cache/index.js.map +1 -0
- package/dist/cache/types.d.ts +328 -0
- package/dist/cache/types.d.ts.map +1 -0
- package/dist/cache/types.js +8 -0
- package/dist/cache/types.js.map +1 -0
- package/dist/channels/channel-manager.d.ts +39 -0
- package/dist/channels/channel-manager.d.ts.map +1 -0
- package/dist/channels/channel-manager.int.test.d.ts +5 -0
- package/dist/channels/channel-manager.int.test.d.ts.map +1 -0
- package/dist/channels/channel-manager.int.test.js +378 -0
- package/dist/channels/channel-manager.int.test.js.map +1 -0
- package/dist/channels/channel-manager.js +274 -0
- package/dist/channels/channel-manager.js.map +1 -0
- package/dist/channels/index.d.ts +47 -0
- package/dist/channels/index.d.ts.map +1 -0
- package/dist/channels/index.js +48 -0
- package/dist/channels/index.js.map +1 -0
- package/dist/channels/types.d.ts +265 -0
- package/dist/channels/types.d.ts.map +1 -0
- package/dist/channels/types.js +39 -0
- package/dist/channels/types.js.map +1 -0
- package/dist/core/ctx-call.int.test.d.ts +7 -0
- package/dist/core/ctx-call.int.test.d.ts.map +1 -0
- package/dist/core/ctx-call.int.test.js +263 -0
- package/dist/core/ctx-call.int.test.js.map +1 -0
- package/dist/core/event-delivery.d.ts +38 -0
- package/dist/core/event-delivery.d.ts.map +1 -0
- package/dist/core/event-delivery.js +131 -0
- package/dist/core/event-delivery.js.map +1 -0
- package/dist/core/index.d.ts +7 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +7 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/registry.d.ts +93 -0
- package/dist/core/registry.d.ts.map +1 -0
- package/dist/core/registry.js +107 -0
- package/dist/core/registry.js.map +1 -0
- package/dist/core/registry.unit.test.d.ts +2 -0
- package/dist/core/registry.unit.test.d.ts.map +1 -0
- package/dist/core/registry.unit.test.js +133 -0
- package/dist/core/registry.unit.test.js.map +1 -0
- package/dist/core/router.d.ts +70 -0
- package/dist/core/router.d.ts.map +1 -0
- package/dist/core/router.int.test.d.ts +2 -0
- package/dist/core/router.int.test.d.ts.map +1 -0
- package/dist/core/router.int.test.js +368 -0
- package/dist/core/router.int.test.js.map +1 -0
- package/dist/core/router.js +308 -0
- package/dist/core/router.js.map +1 -0
- package/dist/docs/generators/content-types.d.ts +10 -0
- package/dist/docs/generators/content-types.d.ts.map +1 -0
- package/dist/docs/generators/content-types.js +18 -0
- package/dist/docs/generators/content-types.js.map +1 -0
- package/dist/docs/generators/errors-types.d.ts +409 -0
- package/dist/docs/generators/errors-types.d.ts.map +1 -0
- package/dist/docs/generators/errors-types.js +224 -0
- package/dist/docs/generators/errors-types.js.map +1 -0
- package/dist/docs/generators/errors.d.ts +88 -0
- package/dist/docs/generators/errors.d.ts.map +1 -0
- package/dist/docs/generators/errors.js +224 -0
- package/dist/docs/generators/errors.js.map +1 -0
- package/dist/docs/generators/generators.int.test.d.ts +2 -0
- package/dist/docs/generators/generators.int.test.d.ts.map +1 -0
- package/dist/docs/generators/generators.int.test.js +105 -0
- package/dist/docs/generators/generators.int.test.js.map +1 -0
- package/dist/docs/generators/grpc-generator.d.ts +53 -0
- package/dist/docs/generators/grpc-generator.d.ts.map +1 -0
- package/dist/docs/generators/grpc-generator.js +109 -0
- package/dist/docs/generators/grpc-generator.js.map +1 -0
- package/dist/docs/generators/http-generator.d.ts +49 -0
- package/dist/docs/generators/http-generator.d.ts.map +1 -0
- package/dist/docs/generators/http-generator.js +561 -0
- package/dist/docs/generators/http-generator.js.map +1 -0
- package/dist/docs/generators/index.d.ts +17 -0
- package/dist/docs/generators/index.d.ts.map +1 -0
- package/dist/docs/generators/index.js +30 -0
- package/dist/docs/generators/index.js.map +1 -0
- package/dist/docs/generators/jsonrpc-generator.d.ts +53 -0
- package/dist/docs/generators/jsonrpc-generator.d.ts.map +1 -0
- package/dist/docs/generators/jsonrpc-generator.js +111 -0
- package/dist/docs/generators/jsonrpc-generator.js.map +1 -0
- package/dist/docs/generators/schema-converter.d.ts +117 -0
- package/dist/docs/generators/schema-converter.d.ts.map +1 -0
- package/dist/docs/generators/schema-converter.js +370 -0
- package/dist/docs/generators/schema-converter.js.map +1 -0
- package/dist/docs/generators/streams-generator.d.ts +85 -0
- package/dist/docs/generators/streams-generator.d.ts.map +1 -0
- package/dist/docs/generators/streams-generator.js +282 -0
- package/dist/docs/generators/streams-generator.js.map +1 -0
- package/dist/docs/generators/tcp-generator.d.ts +133 -0
- package/dist/docs/generators/tcp-generator.d.ts.map +1 -0
- package/dist/docs/generators/tcp-generator.js +227 -0
- package/dist/docs/generators/tcp-generator.js.map +1 -0
- package/dist/docs/generators/udp-generator.d.ts +119 -0
- package/dist/docs/generators/udp-generator.d.ts.map +1 -0
- package/dist/docs/generators/udp-generator.js +241 -0
- package/dist/docs/generators/udp-generator.js.map +1 -0
- package/dist/docs/generators/usd-generator.d.ts +182 -0
- package/dist/docs/generators/usd-generator.d.ts.map +1 -0
- package/dist/docs/generators/usd-generator.js +473 -0
- package/dist/docs/generators/usd-generator.js.map +1 -0
- package/dist/docs/generators/websocket-generator.d.ts +49 -0
- package/dist/docs/generators/websocket-generator.d.ts.map +1 -0
- package/dist/docs/generators/websocket-generator.js +319 -0
- package/dist/docs/generators/websocket-generator.js.map +1 -0
- package/dist/docs/index.d.ts +31 -0
- package/dist/docs/index.d.ts.map +1 -0
- package/dist/docs/index.js +56 -0
- package/dist/docs/index.js.map +1 -0
- package/dist/docs/openapi/generator.d.ts +164 -0
- package/dist/docs/openapi/generator.d.ts.map +1 -0
- package/dist/docs/openapi/generator.int.test.d.ts +5 -0
- package/dist/docs/openapi/generator.int.test.d.ts.map +1 -0
- package/dist/docs/openapi/generator.int.test.js +260 -0
- package/dist/docs/openapi/generator.int.test.js.map +1 -0
- package/dist/docs/openapi/generator.js +690 -0
- package/dist/docs/openapi/generator.js.map +1 -0
- package/dist/docs/openapi/index.d.ts +7 -0
- package/dist/docs/openapi/index.d.ts.map +1 -0
- package/dist/docs/openapi/index.js +7 -0
- package/dist/docs/openapi/index.js.map +1 -0
- package/dist/docs/ui/html-builder.d.ts +19 -0
- package/dist/docs/ui/html-builder.d.ts.map +1 -0
- package/dist/docs/ui/html-builder.js +3065 -0
- package/dist/docs/ui/html-builder.js.map +1 -0
- package/dist/docs/ui/index.d.ts +8 -0
- package/dist/docs/ui/index.d.ts.map +1 -0
- package/dist/docs/ui/index.js +7 -0
- package/dist/docs/ui/index.js.map +1 -0
- package/dist/docs/ui/styles.d.ts +14 -0
- package/dist/docs/ui/styles.d.ts.map +1 -0
- package/dist/docs/ui/styles.js +2228 -0
- package/dist/docs/ui/styles.js.map +1 -0
- package/dist/docs/ui/types.d.ts +68 -0
- package/dist/docs/ui/types.d.ts.map +1 -0
- package/dist/docs/ui/types.js +7 -0
- package/dist/docs/ui/types.js.map +1 -0
- package/dist/docs/ui/utils.d.ts +24 -0
- package/dist/docs/ui/utils.d.ts.map +1 -0
- package/dist/docs/ui/utils.js +55 -0
- package/dist/docs/ui/utils.js.map +1 -0
- package/dist/docs/usd-middleware.d.ts +157 -0
- package/dist/docs/usd-middleware.d.ts.map +1 -0
- package/dist/docs/usd-middleware.js +118 -0
- package/dist/docs/usd-middleware.js.map +1 -0
- package/dist/dx/health/health.int.test.d.ts +5 -0
- package/dist/dx/health/health.int.test.d.ts.map +1 -0
- package/dist/dx/health/health.int.test.js +249 -0
- package/dist/dx/health/health.int.test.js.map +1 -0
- package/dist/dx/health/index.d.ts +82 -0
- package/dist/dx/health/index.d.ts.map +1 -0
- package/dist/dx/health/index.js +260 -0
- package/dist/dx/health/index.js.map +1 -0
- package/dist/dx/health/types.d.ts +104 -0
- package/dist/dx/health/types.d.ts.map +1 -0
- package/dist/dx/health/types.js +7 -0
- package/dist/dx/health/types.js.map +1 -0
- package/dist/dx/index.d.ts +12 -0
- package/dist/dx/index.d.ts.map +1 -0
- package/dist/dx/index.js +15 -0
- package/dist/dx/index.js.map +1 -0
- package/dist/dx/logging/formats.d.ts +46 -0
- package/dist/dx/logging/formats.d.ts.map +1 -0
- package/dist/dx/logging/formats.js +225 -0
- package/dist/dx/logging/formats.js.map +1 -0
- package/dist/dx/logging/http-logging.int.test.d.ts +5 -0
- package/dist/dx/logging/http-logging.int.test.d.ts.map +1 -0
- package/dist/dx/logging/http-logging.int.test.js +319 -0
- package/dist/dx/logging/http-logging.int.test.js.map +1 -0
- package/dist/dx/logging/index.d.ts +84 -0
- package/dist/dx/logging/index.d.ts.map +1 -0
- package/dist/dx/logging/index.js +164 -0
- package/dist/dx/logging/index.js.map +1 -0
- package/dist/dx/logging/types.d.ts +76 -0
- package/dist/dx/logging/types.d.ts.map +1 -0
- package/dist/dx/logging/types.js +7 -0
- package/dist/dx/logging/types.js.map +1 -0
- package/dist/errors/codes.d.ts +239 -0
- package/dist/errors/codes.d.ts.map +1 -0
- package/dist/errors/codes.js +286 -0
- package/dist/errors/codes.js.map +1 -0
- package/dist/errors/factories.d.ts +142 -0
- package/dist/errors/factories.d.ts.map +1 -0
- package/dist/errors/factories.js +201 -0
- package/dist/errors/factories.js.map +1 -0
- package/dist/errors/factories.unit.test.d.ts +7 -0
- package/dist/errors/factories.unit.test.d.ts.map +1 -0
- package/dist/errors/factories.unit.test.js +358 -0
- package/dist/errors/factories.unit.test.js.map +1 -0
- package/dist/errors/index.d.ts +9 -0
- package/dist/errors/index.d.ts.map +1 -0
- package/dist/errors/index.js +11 -0
- package/dist/errors/index.js.map +1 -0
- package/dist/graphql/adapter.d.ts +28 -0
- package/dist/graphql/adapter.d.ts.map +1 -0
- package/dist/graphql/adapter.js +624 -0
- package/dist/graphql/adapter.js.map +1 -0
- package/dist/graphql/index.d.ts +35 -0
- package/dist/graphql/index.d.ts.map +1 -0
- package/dist/graphql/index.js +35 -0
- package/dist/graphql/index.js.map +1 -0
- package/dist/graphql/schema-generator.d.ts +23 -0
- package/dist/graphql/schema-generator.d.ts.map +1 -0
- package/dist/graphql/schema-generator.int.test.d.ts +5 -0
- package/dist/graphql/schema-generator.int.test.d.ts.map +1 -0
- package/dist/graphql/schema-generator.int.test.js +51 -0
- package/dist/graphql/schema-generator.int.test.js.map +1 -0
- package/dist/graphql/schema-generator.js +502 -0
- package/dist/graphql/schema-generator.js.map +1 -0
- package/dist/graphql/types.d.ts +172 -0
- package/dist/graphql/types.d.ts.map +1 -0
- package/dist/graphql/types.js +7 -0
- package/dist/graphql/types.js.map +1 -0
- package/dist/http/app.d.ts +156 -0
- package/dist/http/app.d.ts.map +1 -0
- package/dist/http/app.js +421 -0
- package/dist/http/app.js.map +1 -0
- package/dist/http/auth.d.ts +617 -0
- package/dist/http/auth.d.ts.map +1 -0
- package/dist/http/auth.js +913 -0
- package/dist/http/auth.js.map +1 -0
- package/dist/http/banner.d.ts +118 -0
- package/dist/http/banner.d.ts.map +1 -0
- package/dist/http/banner.js +187 -0
- package/dist/http/banner.js.map +1 -0
- package/dist/http/body-limit.d.ts +80 -0
- package/dist/http/body-limit.d.ts.map +1 -0
- package/dist/http/body-limit.js +187 -0
- package/dist/http/body-limit.js.map +1 -0
- package/dist/http/compress.d.ts +67 -0
- package/dist/http/compress.d.ts.map +1 -0
- package/dist/http/compress.js +226 -0
- package/dist/http/compress.js.map +1 -0
- package/dist/http/context-helpers.d.ts +171 -0
- package/dist/http/context-helpers.d.ts.map +1 -0
- package/dist/http/context-helpers.js +325 -0
- package/dist/http/context-helpers.js.map +1 -0
- package/dist/http/context.d.ts +157 -0
- package/dist/http/context.d.ts.map +1 -0
- package/dist/http/context.js +217 -0
- package/dist/http/context.js.map +1 -0
- package/dist/http/cookie.d.ts +291 -0
- package/dist/http/cookie.d.ts.map +1 -0
- package/dist/http/cookie.js +585 -0
- package/dist/http/cookie.js.map +1 -0
- package/dist/http/cors.d.ts +95 -0
- package/dist/http/cors.d.ts.map +1 -0
- package/dist/http/cors.js +177 -0
- package/dist/http/cors.js.map +1 -0
- package/dist/http/errors.d.ts +286 -0
- package/dist/http/errors.d.ts.map +1 -0
- package/dist/http/errors.js +487 -0
- package/dist/http/errors.js.map +1 -0
- package/dist/http/events.d.ts +251 -0
- package/dist/http/events.d.ts.map +1 -0
- package/dist/http/events.js +321 -0
- package/dist/http/events.js.map +1 -0
- package/dist/http/failban.d.ts +230 -0
- package/dist/http/failban.d.ts.map +1 -0
- package/dist/http/failban.js +351 -0
- package/dist/http/failban.js.map +1 -0
- package/dist/http/guards.d.ts +210 -0
- package/dist/http/guards.d.ts.map +1 -0
- package/dist/http/guards.js +327 -0
- package/dist/http/guards.js.map +1 -0
- package/dist/http/health.d.ts +197 -0
- package/dist/http/health.d.ts.map +1 -0
- package/dist/http/health.js +255 -0
- package/dist/http/health.js.map +1 -0
- package/dist/http/index.d.ts +64 -0
- package/dist/http/index.d.ts.map +1 -0
- package/dist/http/index.js +130 -0
- package/dist/http/index.js.map +1 -0
- package/dist/http/oauth2.d.ts +280 -0
- package/dist/http/oauth2.d.ts.map +1 -0
- package/dist/http/oauth2.js +503 -0
- package/dist/http/oauth2.js.map +1 -0
- package/dist/http/oidc.d.ts +310 -0
- package/dist/http/oidc.d.ts.map +1 -0
- package/dist/http/oidc.js +470 -0
- package/dist/http/oidc.js.map +1 -0
- package/dist/http/rate-limit.d.ts +312 -0
- package/dist/http/rate-limit.d.ts.map +1 -0
- package/dist/http/rate-limit.js +522 -0
- package/dist/http/rate-limit.js.map +1 -0
- package/dist/http/response.d.ts +239 -0
- package/dist/http/response.d.ts.map +1 -0
- package/dist/http/response.js +352 -0
- package/dist/http/response.js.map +1 -0
- package/dist/http/security.d.ts +233 -0
- package/dist/http/security.d.ts.map +1 -0
- package/dist/http/security.js +230 -0
- package/dist/http/security.js.map +1 -0
- package/dist/http/serve.d.ts +72 -0
- package/dist/http/serve.d.ts.map +1 -0
- package/dist/http/serve.js +200 -0
- package/dist/http/serve.js.map +1 -0
- package/dist/http/session.d.ts +279 -0
- package/dist/http/session.d.ts.map +1 -0
- package/dist/http/session.js +354 -0
- package/dist/http/session.js.map +1 -0
- package/dist/http/static-s3.d.ts +176 -0
- package/dist/http/static-s3.d.ts.map +1 -0
- package/dist/http/static-s3.js +282 -0
- package/dist/http/static-s3.js.map +1 -0
- package/dist/http/static.d.ts +111 -0
- package/dist/http/static.d.ts.map +1 -0
- package/dist/http/static.js +373 -0
- package/dist/http/static.js.map +1 -0
- package/dist/http/stream-auth.d.ts +312 -0
- package/dist/http/stream-auth.d.ts.map +1 -0
- package/dist/http/stream-auth.js +404 -0
- package/dist/http/stream-auth.js.map +1 -0
- package/dist/http/templates.d.ts +262 -0
- package/dist/http/templates.d.ts.map +1 -0
- package/dist/http/templates.js +457 -0
- package/dist/http/templates.js.map +1 -0
- package/dist/http/types.d.ts +97 -0
- package/dist/http/types.d.ts.map +1 -0
- package/dist/http/types.js +59 -0
- package/dist/http/types.js.map +1 -0
- package/dist/http/validate.d.ts +197 -0
- package/dist/http/validate.d.ts.map +1 -0
- package/dist/http/validate.js +437 -0
- package/dist/http/validate.js.map +1 -0
- package/dist/http/web-types.d.ts +38 -0
- package/dist/http/web-types.d.ts.map +1 -0
- package/dist/http/web-types.js +9 -0
- package/dist/http/web-types.js.map +1 -0
- package/dist/index.d.ts +45 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +96 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp/cli.d.ts +18 -0
- package/dist/mcp/cli.d.ts.map +1 -0
- package/dist/mcp/cli.js +185 -0
- package/dist/mcp/cli.js.map +1 -0
- package/dist/mcp/docs/adapters.d.ts +10 -0
- package/dist/mcp/docs/adapters.d.ts.map +1 -0
- package/dist/mcp/docs/adapters.js +891 -0
- package/dist/mcp/docs/adapters.js.map +1 -0
- package/dist/mcp/docs/errors.d.ts +11 -0
- package/dist/mcp/docs/errors.d.ts.map +1 -0
- package/dist/mcp/docs/errors.js +549 -0
- package/dist/mcp/docs/errors.js.map +1 -0
- package/dist/mcp/docs/index.d.ts +38 -0
- package/dist/mcp/docs/index.d.ts.map +1 -0
- package/dist/mcp/docs/index.js +94 -0
- package/dist/mcp/docs/index.js.map +1 -0
- package/dist/mcp/docs/interceptors.d.ts +18 -0
- package/dist/mcp/docs/interceptors.d.ts.map +1 -0
- package/dist/mcp/docs/interceptors.js +872 -0
- package/dist/mcp/docs/interceptors.js.map +1 -0
- package/dist/mcp/docs/patterns.d.ts +12 -0
- package/dist/mcp/docs/patterns.d.ts.map +1 -0
- package/dist/mcp/docs/patterns.js +1099 -0
- package/dist/mcp/docs/patterns.js.map +1 -0
- package/dist/mcp/docs/quickstart.d.ts +52 -0
- package/dist/mcp/docs/quickstart.d.ts.map +1 -0
- package/dist/mcp/docs/quickstart.js +682 -0
- package/dist/mcp/docs/quickstart.js.map +1 -0
- package/dist/mcp/index.d.ts +14 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/index.js +18 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/mcp/prompts/index.d.ts +11 -0
- package/dist/mcp/prompts/index.d.ts.map +1 -0
- package/dist/mcp/prompts/index.js +596 -0
- package/dist/mcp/prompts/index.js.map +1 -0
- package/dist/mcp/resources/index.d.ts +10 -0
- package/dist/mcp/resources/index.d.ts.map +1 -0
- package/dist/mcp/resources/index.js +262 -0
- package/dist/mcp/resources/index.js.map +1 -0
- package/dist/mcp/server.d.ts +35 -0
- package/dist/mcp/server.d.ts.map +1 -0
- package/dist/mcp/server.js +452 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/mcp/tools/definitions.d.ts +15 -0
- package/dist/mcp/tools/definitions.d.ts.map +1 -0
- package/dist/mcp/tools/definitions.js +395 -0
- package/dist/mcp/tools/definitions.js.map +1 -0
- package/dist/mcp/tools/handlers.d.ts +8 -0
- package/dist/mcp/tools/handlers.d.ts.map +1 -0
- package/dist/mcp/tools/handlers.js +883 -0
- package/dist/mcp/tools/handlers.js.map +1 -0
- package/dist/mcp/tools/index.d.ts +8 -0
- package/dist/mcp/tools/index.d.ts.map +1 -0
- package/dist/mcp/tools/index.js +8 -0
- package/dist/mcp/tools/index.js.map +1 -0
- package/dist/mcp/types.d.ts +248 -0
- package/dist/mcp/types.d.ts.map +1 -0
- package/dist/mcp/types.js +13 -0
- package/dist/mcp/types.js.map +1 -0
- package/dist/metrics/exporters.d.ts +20 -0
- package/dist/metrics/exporters.d.ts.map +1 -0
- package/dist/metrics/exporters.js +122 -0
- package/dist/metrics/exporters.js.map +1 -0
- package/dist/metrics/index.d.ts +11 -0
- package/dist/metrics/index.d.ts.map +1 -0
- package/dist/metrics/index.js +10 -0
- package/dist/metrics/index.js.map +1 -0
- package/dist/metrics/interceptor.d.ts +29 -0
- package/dist/metrics/interceptor.d.ts.map +1 -0
- package/dist/metrics/interceptor.js +146 -0
- package/dist/metrics/interceptor.js.map +1 -0
- package/dist/metrics/metrics.int.test.d.ts +5 -0
- package/dist/metrics/metrics.int.test.d.ts.map +1 -0
- package/dist/metrics/metrics.int.test.js +288 -0
- package/dist/metrics/metrics.int.test.js.map +1 -0
- package/dist/metrics/registry.d.ts +11 -0
- package/dist/metrics/registry.d.ts.map +1 -0
- package/dist/metrics/registry.js +178 -0
- package/dist/metrics/registry.js.map +1 -0
- package/dist/metrics/types.d.ts +107 -0
- package/dist/metrics/types.d.ts.map +1 -0
- package/dist/metrics/types.js +21 -0
- package/dist/metrics/types.js.map +1 -0
- package/dist/middleware/auth.d.ts +231 -0
- package/dist/middleware/auth.d.ts.map +1 -0
- package/dist/middleware/auth.int.test.d.ts +5 -0
- package/dist/middleware/auth.int.test.d.ts.map +1 -0
- package/dist/middleware/auth.int.test.js +366 -0
- package/dist/middleware/auth.int.test.js.map +1 -0
- package/dist/middleware/auth.js +413 -0
- package/dist/middleware/auth.js.map +1 -0
- package/dist/middleware/compose.d.ts +102 -0
- package/dist/middleware/compose.d.ts.map +1 -0
- package/dist/middleware/compose.int.test.d.ts +7 -0
- package/dist/middleware/compose.int.test.d.ts.map +1 -0
- package/dist/middleware/compose.int.test.js +238 -0
- package/dist/middleware/compose.int.test.js.map +1 -0
- package/dist/middleware/compose.js +152 -0
- package/dist/middleware/compose.js.map +1 -0
- package/dist/middleware/http/compression.d.ts +92 -0
- package/dist/middleware/http/compression.d.ts.map +1 -0
- package/dist/middleware/http/compression.js +264 -0
- package/dist/middleware/http/compression.js.map +1 -0
- package/dist/middleware/http/index.d.ts +10 -0
- package/dist/middleware/http/index.d.ts.map +1 -0
- package/dist/middleware/http/index.js +11 -0
- package/dist/middleware/http/index.js.map +1 -0
- package/dist/middleware/http/security.d.ts +71 -0
- package/dist/middleware/http/security.d.ts.map +1 -0
- package/dist/middleware/http/security.js +263 -0
- package/dist/middleware/http/security.js.map +1 -0
- package/dist/middleware/index.d.ts +28 -0
- package/dist/middleware/index.d.ts.map +1 -0
- package/dist/middleware/index.js +58 -0
- package/dist/middleware/index.js.map +1 -0
- package/dist/middleware/interceptors/bulkhead.d.ts +104 -0
- package/dist/middleware/interceptors/bulkhead.d.ts.map +1 -0
- package/dist/middleware/interceptors/bulkhead.int.test.d.ts +5 -0
- package/dist/middleware/interceptors/bulkhead.int.test.d.ts.map +1 -0
- package/dist/middleware/interceptors/bulkhead.int.test.js +263 -0
- package/dist/middleware/interceptors/bulkhead.int.test.js.map +1 -0
- package/dist/middleware/interceptors/bulkhead.js +260 -0
- package/dist/middleware/interceptors/bulkhead.js.map +1 -0
- package/dist/middleware/interceptors/cache.d.ts +218 -0
- package/dist/middleware/interceptors/cache.d.ts.map +1 -0
- package/dist/middleware/interceptors/cache.int.test.d.ts +5 -0
- package/dist/middleware/interceptors/cache.int.test.d.ts.map +1 -0
- package/dist/middleware/interceptors/cache.int.test.js +470 -0
- package/dist/middleware/interceptors/cache.int.test.js.map +1 -0
- package/dist/middleware/interceptors/cache.js +505 -0
- package/dist/middleware/interceptors/cache.js.map +1 -0
- package/dist/middleware/interceptors/circuit-breaker.d.ts +72 -0
- package/dist/middleware/interceptors/circuit-breaker.d.ts.map +1 -0
- package/dist/middleware/interceptors/circuit-breaker.int.test.d.ts +5 -0
- package/dist/middleware/interceptors/circuit-breaker.int.test.d.ts.map +1 -0
- package/dist/middleware/interceptors/circuit-breaker.int.test.js +253 -0
- package/dist/middleware/interceptors/circuit-breaker.int.test.js.map +1 -0
- package/dist/middleware/interceptors/circuit-breaker.js +268 -0
- package/dist/middleware/interceptors/circuit-breaker.js.map +1 -0
- package/dist/middleware/interceptors/dedup.d.ts +105 -0
- package/dist/middleware/interceptors/dedup.d.ts.map +1 -0
- package/dist/middleware/interceptors/dedup.js +219 -0
- package/dist/middleware/interceptors/dedup.js.map +1 -0
- package/dist/middleware/interceptors/fallback.d.ts +94 -0
- package/dist/middleware/interceptors/fallback.d.ts.map +1 -0
- package/dist/middleware/interceptors/fallback.int.test.d.ts +5 -0
- package/dist/middleware/interceptors/fallback.int.test.d.ts.map +1 -0
- package/dist/middleware/interceptors/fallback.int.test.js +211 -0
- package/dist/middleware/interceptors/fallback.int.test.js.map +1 -0
- package/dist/middleware/interceptors/fallback.js +161 -0
- package/dist/middleware/interceptors/fallback.js.map +1 -0
- package/dist/middleware/interceptors/index.d.ts +24 -0
- package/dist/middleware/interceptors/index.d.ts.map +1 -0
- package/dist/middleware/interceptors/index.js +28 -0
- package/dist/middleware/interceptors/index.js.map +1 -0
- package/dist/middleware/interceptors/logging.d.ts +62 -0
- package/dist/middleware/interceptors/logging.d.ts.map +1 -0
- package/dist/middleware/interceptors/logging.int.test.d.ts +5 -0
- package/dist/middleware/interceptors/logging.int.test.d.ts.map +1 -0
- package/dist/middleware/interceptors/logging.int.test.js +144 -0
- package/dist/middleware/interceptors/logging.int.test.js.map +1 -0
- package/dist/middleware/interceptors/logging.js +294 -0
- package/dist/middleware/interceptors/logging.js.map +1 -0
- package/dist/middleware/interceptors/rate-limit.d.ts +147 -0
- package/dist/middleware/interceptors/rate-limit.d.ts.map +1 -0
- package/dist/middleware/interceptors/rate-limit.int.test.d.ts +5 -0
- package/dist/middleware/interceptors/rate-limit.int.test.d.ts.map +1 -0
- package/dist/middleware/interceptors/rate-limit.int.test.js +221 -0
- package/dist/middleware/interceptors/rate-limit.int.test.js.map +1 -0
- package/dist/middleware/interceptors/rate-limit.js +376 -0
- package/dist/middleware/interceptors/rate-limit.js.map +1 -0
- package/dist/middleware/interceptors/request-id.d.ts +63 -0
- package/dist/middleware/interceptors/request-id.d.ts.map +1 -0
- package/dist/middleware/interceptors/request-id.int.test.d.ts +5 -0
- package/dist/middleware/interceptors/request-id.int.test.d.ts.map +1 -0
- package/dist/middleware/interceptors/request-id.int.test.js +136 -0
- package/dist/middleware/interceptors/request-id.int.test.js.map +1 -0
- package/dist/middleware/interceptors/request-id.js +119 -0
- package/dist/middleware/interceptors/request-id.js.map +1 -0
- package/dist/middleware/interceptors/retry.d.ts +80 -0
- package/dist/middleware/interceptors/retry.d.ts.map +1 -0
- package/dist/middleware/interceptors/retry.int.test.d.ts +5 -0
- package/dist/middleware/interceptors/retry.int.test.d.ts.map +1 -0
- package/dist/middleware/interceptors/retry.int.test.js +534 -0
- package/dist/middleware/interceptors/retry.int.test.js.map +1 -0
- package/dist/middleware/interceptors/retry.js +275 -0
- package/dist/middleware/interceptors/retry.js.map +1 -0
- package/dist/middleware/interceptors/size-limit.d.ts +145 -0
- package/dist/middleware/interceptors/size-limit.d.ts.map +1 -0
- package/dist/middleware/interceptors/size-limit.js +231 -0
- package/dist/middleware/interceptors/size-limit.js.map +1 -0
- package/dist/middleware/interceptors/timeout.d.ts +121 -0
- package/dist/middleware/interceptors/timeout.d.ts.map +1 -0
- package/dist/middleware/interceptors/timeout.int.test.d.ts +5 -0
- package/dist/middleware/interceptors/timeout.int.test.d.ts.map +1 -0
- package/dist/middleware/interceptors/timeout.int.test.js +228 -0
- package/dist/middleware/interceptors/timeout.int.test.js.map +1 -0
- package/dist/middleware/interceptors/timeout.js +253 -0
- package/dist/middleware/interceptors/timeout.js.map +1 -0
- package/dist/middleware/presets.d.ts +214 -0
- package/dist/middleware/presets.d.ts.map +1 -0
- package/dist/middleware/presets.js +329 -0
- package/dist/middleware/presets.js.map +1 -0
- package/dist/middleware/rate-limit.d.ts +105 -0
- package/dist/middleware/rate-limit.d.ts.map +1 -0
- package/dist/middleware/rate-limit.int.test.d.ts +5 -0
- package/dist/middleware/rate-limit.int.test.d.ts.map +1 -0
- package/dist/middleware/rate-limit.int.test.js +350 -0
- package/dist/middleware/rate-limit.int.test.js.map +1 -0
- package/dist/middleware/rate-limit.js +206 -0
- package/dist/middleware/rate-limit.js.map +1 -0
- package/dist/middleware/types.d.ts +371 -0
- package/dist/middleware/types.d.ts.map +1 -0
- package/dist/middleware/types.js +7 -0
- package/dist/middleware/types.js.map +1 -0
- package/dist/openapi/index.d.ts +9 -0
- package/dist/openapi/index.d.ts.map +1 -0
- package/dist/openapi/index.js +9 -0
- package/dist/openapi/index.js.map +1 -0
- package/dist/rate-limit/drivers/filesystem.d.ts +17 -0
- package/dist/rate-limit/drivers/filesystem.d.ts.map +1 -0
- package/dist/rate-limit/drivers/filesystem.js +85 -0
- package/dist/rate-limit/drivers/filesystem.js.map +1 -0
- package/dist/rate-limit/drivers/memory.d.ts +15 -0
- package/dist/rate-limit/drivers/memory.d.ts.map +1 -0
- package/dist/rate-limit/drivers/memory.js +55 -0
- package/dist/rate-limit/drivers/memory.js.map +1 -0
- package/dist/rate-limit/drivers/redis.d.ts +12 -0
- package/dist/rate-limit/drivers/redis.d.ts.map +1 -0
- package/dist/rate-limit/drivers/redis.js +46 -0
- package/dist/rate-limit/drivers/redis.js.map +1 -0
- package/dist/rate-limit/factory.d.ts +11 -0
- package/dist/rate-limit/factory.d.ts.map +1 -0
- package/dist/rate-limit/factory.js +33 -0
- package/dist/rate-limit/factory.js.map +1 -0
- package/dist/rate-limit/index.d.ts +6 -0
- package/dist/rate-limit/index.d.ts.map +1 -0
- package/dist/rate-limit/index.js +5 -0
- package/dist/rate-limit/index.js.map +1 -0
- package/dist/rate-limit/types.d.ts +51 -0
- package/dist/rate-limit/types.d.ts.map +1 -0
- package/dist/rate-limit/types.js +7 -0
- package/dist/rate-limit/types.js.map +1 -0
- package/dist/server/builder.d.ts +11 -0
- package/dist/server/builder.d.ts.map +1 -0
- package/dist/server/builder.int.test.d.ts +7 -0
- package/dist/server/builder.int.test.d.ts.map +1 -0
- package/dist/server/builder.int.test.js +414 -0
- package/dist/server/builder.int.test.js.map +1 -0
- package/dist/server/builder.js +1682 -0
- package/dist/server/builder.js.map +1 -0
- package/dist/server/channel-utils.d.ts +34 -0
- package/dist/server/channel-utils.d.ts.map +1 -0
- package/dist/server/channel-utils.js +131 -0
- package/dist/server/channel-utils.js.map +1 -0
- package/dist/server/discovery-utils.d.ts +32 -0
- package/dist/server/discovery-utils.d.ts.map +1 -0
- package/dist/server/discovery-utils.js +118 -0
- package/dist/server/discovery-utils.js.map +1 -0
- package/dist/server/errors.d.ts +186 -0
- package/dist/server/errors.d.ts.map +1 -0
- package/dist/server/errors.js +397 -0
- package/dist/server/errors.js.map +1 -0
- package/dist/server/fs-routes/index.d.ts +66 -0
- package/dist/server/fs-routes/index.d.ts.map +1 -0
- package/dist/server/fs-routes/index.js +66 -0
- package/dist/server/fs-routes/index.js.map +1 -0
- package/dist/server/fs-routes/loader.d.ts +28 -0
- package/dist/server/fs-routes/loader.d.ts.map +1 -0
- package/dist/server/fs-routes/loader.int.test.d.ts +5 -0
- package/dist/server/fs-routes/loader.int.test.d.ts.map +1 -0
- package/dist/server/fs-routes/loader.int.test.js +48 -0
- package/dist/server/fs-routes/loader.int.test.js.map +1 -0
- package/dist/server/fs-routes/loader.js +586 -0
- package/dist/server/fs-routes/loader.js.map +1 -0
- package/dist/server/fs-routes/middleware-processor.d.ts +19 -0
- package/dist/server/fs-routes/middleware-processor.d.ts.map +1 -0
- package/dist/server/fs-routes/middleware-processor.js +232 -0
- package/dist/server/fs-routes/middleware-processor.js.map +1 -0
- package/dist/server/fs-routes/resources/index.d.ts +8 -0
- package/dist/server/fs-routes/resources/index.d.ts.map +1 -0
- package/dist/server/fs-routes/resources/index.js +8 -0
- package/dist/server/fs-routes/resources/index.js.map +1 -0
- package/dist/server/fs-routes/resources/loader.d.ts +16 -0
- package/dist/server/fs-routes/resources/loader.d.ts.map +1 -0
- package/dist/server/fs-routes/resources/loader.js +431 -0
- package/dist/server/fs-routes/resources/loader.js.map +1 -0
- package/dist/server/fs-routes/resources/types.d.ts +256 -0
- package/dist/server/fs-routes/resources/types.d.ts.map +1 -0
- package/dist/server/fs-routes/resources/types.js +8 -0
- package/dist/server/fs-routes/resources/types.js.map +1 -0
- package/dist/server/fs-routes/rest/index.d.ts +8 -0
- package/dist/server/fs-routes/rest/index.d.ts.map +1 -0
- package/dist/server/fs-routes/rest/index.js +8 -0
- package/dist/server/fs-routes/rest/index.js.map +1 -0
- package/dist/server/fs-routes/rest/loader.d.ts +11 -0
- package/dist/server/fs-routes/rest/loader.d.ts.map +1 -0
- package/dist/server/fs-routes/rest/loader.js +595 -0
- package/dist/server/fs-routes/rest/loader.js.map +1 -0
- package/dist/server/fs-routes/rest/types.d.ts +288 -0
- package/dist/server/fs-routes/rest/types.d.ts.map +1 -0
- package/dist/server/fs-routes/rest/types.js +50 -0
- package/dist/server/fs-routes/rest/types.js.map +1 -0
- package/dist/server/fs-routes/tcp/index.d.ts +8 -0
- package/dist/server/fs-routes/tcp/index.d.ts.map +1 -0
- package/dist/server/fs-routes/tcp/index.js +8 -0
- package/dist/server/fs-routes/tcp/index.js.map +1 -0
- package/dist/server/fs-routes/tcp/loader.d.ts +15 -0
- package/dist/server/fs-routes/tcp/loader.d.ts.map +1 -0
- package/dist/server/fs-routes/tcp/loader.js +402 -0
- package/dist/server/fs-routes/tcp/loader.js.map +1 -0
- package/dist/server/fs-routes/tcp/types.d.ts +215 -0
- package/dist/server/fs-routes/tcp/types.d.ts.map +1 -0
- package/dist/server/fs-routes/tcp/types.js +7 -0
- package/dist/server/fs-routes/tcp/types.js.map +1 -0
- package/dist/server/fs-routes/types.d.ts +437 -0
- package/dist/server/fs-routes/types.d.ts.map +1 -0
- package/dist/server/fs-routes/types.js +7 -0
- package/dist/server/fs-routes/types.js.map +1 -0
- package/dist/server/fs-routes/udp/index.d.ts +8 -0
- package/dist/server/fs-routes/udp/index.d.ts.map +1 -0
- package/dist/server/fs-routes/udp/index.js +8 -0
- package/dist/server/fs-routes/udp/index.js.map +1 -0
- package/dist/server/fs-routes/udp/loader.d.ts +15 -0
- package/dist/server/fs-routes/udp/loader.d.ts.map +1 -0
- package/dist/server/fs-routes/udp/loader.js +282 -0
- package/dist/server/fs-routes/udp/loader.js.map +1 -0
- package/dist/server/fs-routes/udp/types.d.ts +164 -0
- package/dist/server/fs-routes/udp/types.d.ts.map +1 -0
- package/dist/server/fs-routes/udp/types.js +7 -0
- package/dist/server/fs-routes/udp/types.js.map +1 -0
- package/dist/server/fs-routes/watcher.d.ts +34 -0
- package/dist/server/fs-routes/watcher.d.ts.map +1 -0
- package/dist/server/fs-routes/watcher.js +158 -0
- package/dist/server/fs-routes/watcher.js.map +1 -0
- package/dist/server/handler-builders.d.ts +44 -0
- package/dist/server/handler-builders.d.ts.map +1 -0
- package/dist/server/handler-builders.js +297 -0
- package/dist/server/handler-builders.js.map +1 -0
- package/dist/server/hooks.int.test.d.ts +7 -0
- package/dist/server/hooks.int.test.d.ts.map +1 -0
- package/dist/server/hooks.int.test.js +564 -0
- package/dist/server/hooks.int.test.js.map +1 -0
- package/dist/server/index.d.ts +18 -0
- package/dist/server/index.d.ts.map +1 -0
- package/dist/server/index.js +37 -0
- package/dist/server/index.js.map +1 -0
- package/dist/server/protocol-config.d.ts +22 -0
- package/dist/server/protocol-config.d.ts.map +1 -0
- package/dist/server/protocol-config.js +61 -0
- package/dist/server/protocol-config.js.map +1 -0
- package/dist/server/resource-builder.d.ts +175 -0
- package/dist/server/resource-builder.d.ts.map +1 -0
- package/dist/server/resource-builder.js +212 -0
- package/dist/server/resource-builder.js.map +1 -0
- package/dist/server/rest-middleware.d.ts +45 -0
- package/dist/server/rest-middleware.d.ts.map +1 -0
- package/dist/server/rest-middleware.js +368 -0
- package/dist/server/rest-middleware.js.map +1 -0
- package/dist/server/route-discovery.d.ts +54 -0
- package/dist/server/route-discovery.d.ts.map +1 -0
- package/dist/server/route-discovery.int.test.d.ts +5 -0
- package/dist/server/route-discovery.int.test.d.ts.map +1 -0
- package/dist/server/route-discovery.int.test.js +49 -0
- package/dist/server/route-discovery.int.test.js.map +1 -0
- package/dist/server/route-discovery.js +154 -0
- package/dist/server/route-discovery.js.map +1 -0
- package/dist/server/router-module.d.ts +50 -0
- package/dist/server/router-module.d.ts.map +1 -0
- package/dist/server/router-module.js +250 -0
- package/dist/server/router-module.js.map +1 -0
- package/dist/server/shared-context.d.ts +140 -0
- package/dist/server/shared-context.d.ts.map +1 -0
- package/dist/server/shared-context.js +258 -0
- package/dist/server/shared-context.js.map +1 -0
- package/dist/server/types.d.ts +2160 -0
- package/dist/server/types.d.ts.map +1 -0
- package/dist/server/types.js +7 -0
- package/dist/server/types.js.map +1 -0
- package/dist/stream/index.d.ts +3 -0
- package/dist/stream/index.d.ts.map +1 -0
- package/dist/stream/index.js +2 -0
- package/dist/stream/index.js.map +1 -0
- package/dist/stream/raffel-stream.d.ts +17 -0
- package/dist/stream/raffel-stream.d.ts.map +1 -0
- package/dist/stream/raffel-stream.int.test.d.ts +2 -0
- package/dist/stream/raffel-stream.int.test.d.ts.map +1 -0
- package/dist/stream/raffel-stream.int.test.js +265 -0
- package/dist/stream/raffel-stream.int.test.js.map +1 -0
- package/dist/stream/raffel-stream.js +205 -0
- package/dist/stream/raffel-stream.js.map +1 -0
- package/dist/tracing/exporters.d.ts +47 -0
- package/dist/tracing/exporters.d.ts.map +1 -0
- package/dist/tracing/exporters.js +173 -0
- package/dist/tracing/exporters.js.map +1 -0
- package/dist/tracing/index.d.ts +43 -0
- package/dist/tracing/index.d.ts.map +1 -0
- package/dist/tracing/index.js +46 -0
- package/dist/tracing/index.js.map +1 -0
- package/dist/tracing/interceptor.d.ts +20 -0
- package/dist/tracing/interceptor.d.ts.map +1 -0
- package/dist/tracing/interceptor.js +90 -0
- package/dist/tracing/interceptor.js.map +1 -0
- package/dist/tracing/sampler.d.ts +32 -0
- package/dist/tracing/sampler.d.ts.map +1 -0
- package/dist/tracing/sampler.js +111 -0
- package/dist/tracing/sampler.js.map +1 -0
- package/dist/tracing/span.d.ts +32 -0
- package/dist/tracing/span.d.ts.map +1 -0
- package/dist/tracing/span.js +139 -0
- package/dist/tracing/span.js.map +1 -0
- package/dist/tracing/tracer.d.ts +11 -0
- package/dist/tracing/tracer.d.ts.map +1 -0
- package/dist/tracing/tracer.js +149 -0
- package/dist/tracing/tracer.js.map +1 -0
- package/dist/tracing/tracing.int.test.d.ts +5 -0
- package/dist/tracing/tracing.int.test.d.ts.map +1 -0
- package/dist/tracing/tracing.int.test.js +412 -0
- package/dist/tracing/tracing.int.test.js.map +1 -0
- package/dist/tracing/types.d.ts +175 -0
- package/dist/tracing/types.d.ts.map +1 -0
- package/dist/tracing/types.js +16 -0
- package/dist/tracing/types.js.map +1 -0
- package/dist/types/context.d.ts +96 -0
- package/dist/types/context.d.ts.map +1 -0
- package/dist/types/context.js +55 -0
- package/dist/types/context.js.map +1 -0
- package/dist/types/envelope.d.ts +57 -0
- package/dist/types/envelope.d.ts.map +1 -0
- package/dist/types/envelope.js +39 -0
- package/dist/types/envelope.js.map +1 -0
- package/dist/types/handlers.d.ts +142 -0
- package/dist/types/handlers.d.ts.map +1 -0
- package/dist/types/handlers.js +7 -0
- package/dist/types/handlers.js.map +1 -0
- package/dist/types/index.d.ts +7 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +3 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/stream.d.ts +69 -0
- package/dist/types/stream.d.ts.map +1 -0
- package/dist/types/stream.js +7 -0
- package/dist/types/stream.js.map +1 -0
- package/dist/ui/core/event-delivery.d.ts +38 -0
- package/dist/ui/core/event-delivery.d.ts.map +1 -0
- package/dist/ui/core/registry.d.ts +93 -0
- package/dist/ui/core/registry.d.ts.map +1 -0
- package/dist/ui/core/router.d.ts +70 -0
- package/dist/ui/core/router.d.ts.map +1 -0
- package/dist/ui/docs/openapi/generator.d.ts +164 -0
- package/dist/ui/docs/openapi/generator.d.ts.map +1 -0
- package/dist/ui/docs/openapi/index.d.ts +7 -0
- package/dist/ui/docs/openapi/index.d.ts.map +1 -0
- package/dist/ui/docs/ui/html-builder.d.ts +19 -0
- package/dist/ui/docs/ui/html-builder.d.ts.map +1 -0
- package/dist/ui/docs/ui/index.d.ts +8 -0
- package/dist/ui/docs/ui/index.d.ts.map +1 -0
- package/dist/ui/docs/ui/styles.d.ts +14 -0
- package/dist/ui/docs/ui/styles.d.ts.map +1 -0
- package/dist/ui/docs/ui/types.d.ts +68 -0
- package/dist/ui/docs/ui/types.d.ts.map +1 -0
- package/dist/ui/docs/ui/utils.d.ts +24 -0
- package/dist/ui/docs/ui/utils.d.ts.map +1 -0
- package/dist/ui/errors/codes.d.ts +239 -0
- package/dist/ui/errors/codes.d.ts.map +1 -0
- package/dist/ui/types/context.d.ts +96 -0
- package/dist/ui/types/context.d.ts.map +1 -0
- package/dist/ui/types/envelope.d.ts +57 -0
- package/dist/ui/types/envelope.d.ts.map +1 -0
- package/dist/ui/types/handlers.d.ts +142 -0
- package/dist/ui/types/handlers.d.ts.map +1 -0
- package/dist/ui/types/index.d.ts +7 -0
- package/dist/ui/types/index.d.ts.map +1 -0
- package/dist/ui/types/stream.d.ts +69 -0
- package/dist/ui/types/stream.d.ts.map +1 -0
- package/dist/ui/usd/builder/document.d.ts +190 -0
- package/dist/ui/usd/builder/document.d.ts.map +1 -0
- package/dist/ui/usd/builder/grpc.d.ts +119 -0
- package/dist/ui/usd/builder/grpc.d.ts.map +1 -0
- package/dist/ui/usd/builder/http.d.ts +131 -0
- package/dist/ui/usd/builder/http.d.ts.map +1 -0
- package/dist/ui/usd/builder/index.d.ts +15 -0
- package/dist/ui/usd/builder/index.d.ts.map +1 -0
- package/dist/ui/usd/builder/jsonrpc.d.ts +96 -0
- package/dist/ui/usd/builder/jsonrpc.d.ts.map +1 -0
- package/dist/ui/usd/builder/schema.d.ts +143 -0
- package/dist/ui/usd/builder/schema.d.ts.map +1 -0
- package/dist/ui/usd/builder/streams.d.ts +71 -0
- package/dist/ui/usd/builder/streams.d.ts.map +1 -0
- package/dist/ui/usd/builder/tcp.d.ts +61 -0
- package/dist/ui/usd/builder/tcp.d.ts.map +1 -0
- package/dist/ui/usd/builder/udp.d.ts +64 -0
- package/dist/ui/usd/builder/udp.d.ts.map +1 -0
- package/dist/ui/usd/builder/websocket.d.ts +131 -0
- package/dist/ui/usd/builder/websocket.d.ts.map +1 -0
- package/dist/ui/usd/export/index.d.ts +8 -0
- package/dist/ui/usd/export/index.d.ts.map +1 -0
- package/dist/ui/usd/export/openapi.d.ts +75 -0
- package/dist/ui/usd/export/openapi.d.ts.map +1 -0
- package/dist/ui/usd/index.d.ts +58 -0
- package/dist/ui/usd/index.d.ts.map +1 -0
- package/dist/ui/usd/parser/index.d.ts +93 -0
- package/dist/ui/usd/parser/index.d.ts.map +1 -0
- package/dist/ui/usd/parser/json.d.ts +34 -0
- package/dist/ui/usd/parser/json.d.ts.map +1 -0
- package/dist/ui/usd/parser/normalize.d.ts +20 -0
- package/dist/ui/usd/parser/normalize.d.ts.map +1 -0
- package/dist/ui/usd/parser/yaml.d.ts +41 -0
- package/dist/ui/usd/parser/yaml.d.ts.map +1 -0
- package/dist/ui/usd/spec/defaults.d.ts +121 -0
- package/dist/ui/usd/spec/defaults.d.ts.map +1 -0
- package/dist/ui/usd/spec/types.d.ts +704 -0
- package/dist/ui/usd/spec/types.d.ts.map +1 -0
- package/dist/ui/usd/utils/index.d.ts +6 -0
- package/dist/ui/usd/utils/index.d.ts.map +1 -0
- package/dist/ui/usd/utils/merge.d.ts +29 -0
- package/dist/ui/usd/utils/merge.d.ts.map +1 -0
- package/dist/ui/usd/utils/refs.d.ts +46 -0
- package/dist/ui/usd/utils/refs.d.ts.map +1 -0
- package/dist/ui/usd/validator/errors.d.ts +66 -0
- package/dist/ui/usd/validator/errors.d.ts.map +1 -0
- package/dist/ui/usd/validator/index.d.ts +68 -0
- package/dist/ui/usd/validator/index.d.ts.map +1 -0
- package/dist/ui/usd/validator/schema.d.ts +905 -0
- package/dist/ui/usd/validator/schema.d.ts.map +1 -0
- package/dist/ui/usd/validator/semantic.d.ts +15 -0
- package/dist/ui/usd/validator/semantic.d.ts.map +1 -0
- package/dist/ui/utils/id/alphabets.d.ts +68 -0
- package/dist/ui/utils/id/alphabets.d.ts.map +1 -0
- package/dist/ui/utils/id/entropy.d.ts +45 -0
- package/dist/ui/utils/id/entropy.d.ts.map +1 -0
- package/dist/ui/utils/id/index.d.ts +15 -0
- package/dist/ui/utils/id/index.d.ts.map +1 -0
- package/dist/ui/utils/id/sid.d.ts +86 -0
- package/dist/ui/utils/id/sid.d.ts.map +1 -0
- package/dist/ui/validation/adapters/ajv.d.ts +59 -0
- package/dist/ui/validation/adapters/ajv.d.ts.map +1 -0
- package/dist/ui/validation/adapters/fastest.d.ts +52 -0
- package/dist/ui/validation/adapters/fastest.d.ts.map +1 -0
- package/dist/ui/validation/adapters/index.d.ts +19 -0
- package/dist/ui/validation/adapters/index.d.ts.map +1 -0
- package/dist/ui/validation/adapters/joi.d.ts +51 -0
- package/dist/ui/validation/adapters/joi.d.ts.map +1 -0
- package/dist/ui/validation/adapters/yup.d.ts +53 -0
- package/dist/ui/validation/adapters/yup.d.ts.map +1 -0
- package/dist/ui/validation/adapters/zod.d.ts +52 -0
- package/dist/ui/validation/adapters/zod.d.ts.map +1 -0
- package/dist/ui/validation/index.d.ts +26 -0
- package/dist/ui/validation/index.d.ts.map +1 -0
- package/dist/ui/validation/schema.d.ts +150 -0
- package/dist/ui/validation/schema.d.ts.map +1 -0
- package/dist/ui/validation/types.d.ts +72 -0
- package/dist/ui/validation/types.d.ts.map +1 -0
- package/dist/usd/builder/document.d.ts +190 -0
- package/dist/usd/builder/document.d.ts.map +1 -0
- package/dist/usd/builder/document.js +418 -0
- package/dist/usd/builder/document.js.map +1 -0
- package/dist/usd/builder/grpc.d.ts +119 -0
- package/dist/usd/builder/grpc.d.ts.map +1 -0
- package/dist/usd/builder/grpc.js +220 -0
- package/dist/usd/builder/grpc.js.map +1 -0
- package/dist/usd/builder/http.d.ts +131 -0
- package/dist/usd/builder/http.d.ts.map +1 -0
- package/dist/usd/builder/http.js +248 -0
- package/dist/usd/builder/http.js.map +1 -0
- package/dist/usd/builder/index.d.ts +15 -0
- package/dist/usd/builder/index.d.ts.map +1 -0
- package/dist/usd/builder/index.js +18 -0
- package/dist/usd/builder/index.js.map +1 -0
- package/dist/usd/builder/jsonrpc.d.ts +96 -0
- package/dist/usd/builder/jsonrpc.d.ts.map +1 -0
- package/dist/usd/builder/jsonrpc.js +167 -0
- package/dist/usd/builder/jsonrpc.js.map +1 -0
- package/dist/usd/builder/schema.d.ts +143 -0
- package/dist/usd/builder/schema.d.ts.map +1 -0
- package/dist/usd/builder/schema.js +171 -0
- package/dist/usd/builder/schema.js.map +1 -0
- package/dist/usd/builder/streams.d.ts +71 -0
- package/dist/usd/builder/streams.d.ts.map +1 -0
- package/dist/usd/builder/streams.js +146 -0
- package/dist/usd/builder/streams.js.map +1 -0
- package/dist/usd/builder/tcp.d.ts +61 -0
- package/dist/usd/builder/tcp.d.ts.map +1 -0
- package/dist/usd/builder/tcp.js +150 -0
- package/dist/usd/builder/tcp.js.map +1 -0
- package/dist/usd/builder/udp.d.ts +64 -0
- package/dist/usd/builder/udp.d.ts.map +1 -0
- package/dist/usd/builder/udp.js +166 -0
- package/dist/usd/builder/udp.js.map +1 -0
- package/dist/usd/builder/websocket.d.ts +131 -0
- package/dist/usd/builder/websocket.d.ts.map +1 -0
- package/dist/usd/builder/websocket.js +218 -0
- package/dist/usd/builder/websocket.js.map +1 -0
- package/dist/usd/export/index.d.ts +8 -0
- package/dist/usd/export/index.d.ts.map +1 -0
- package/dist/usd/export/index.js +10 -0
- package/dist/usd/export/index.js.map +1 -0
- package/dist/usd/export/openapi.d.ts +75 -0
- package/dist/usd/export/openapi.d.ts.map +1 -0
- package/dist/usd/export/openapi.js +296 -0
- package/dist/usd/export/openapi.js.map +1 -0
- package/dist/usd/index.d.ts +58 -0
- package/dist/usd/index.d.ts.map +1 -0
- package/dist/usd/index.js +61 -0
- package/dist/usd/index.js.map +1 -0
- package/dist/usd/parser/index.d.ts +93 -0
- package/dist/usd/parser/index.d.ts.map +1 -0
- package/dist/usd/parser/index.js +137 -0
- package/dist/usd/parser/index.js.map +1 -0
- package/dist/usd/parser/json.d.ts +34 -0
- package/dist/usd/parser/json.d.ts.map +1 -0
- package/dist/usd/parser/json.js +68 -0
- package/dist/usd/parser/json.js.map +1 -0
- package/dist/usd/parser/normalize.d.ts +20 -0
- package/dist/usd/parser/normalize.d.ts.map +1 -0
- package/dist/usd/parser/normalize.js +271 -0
- package/dist/usd/parser/normalize.js.map +1 -0
- package/dist/usd/parser/yaml.d.ts +41 -0
- package/dist/usd/parser/yaml.d.ts.map +1 -0
- package/dist/usd/parser/yaml.js +66 -0
- package/dist/usd/parser/yaml.js.map +1 -0
- package/dist/usd/spec/defaults.d.ts +121 -0
- package/dist/usd/spec/defaults.d.ts.map +1 -0
- package/dist/usd/spec/defaults.js +204 -0
- package/dist/usd/spec/defaults.js.map +1 -0
- package/dist/usd/spec/index.d.ts +6 -0
- package/dist/usd/spec/index.d.ts.map +1 -0
- package/dist/usd/spec/index.js +6 -0
- package/dist/usd/spec/index.js.map +1 -0
- package/dist/usd/spec/types.d.ts +698 -0
- package/dist/usd/spec/types.d.ts.map +1 -0
- package/dist/usd/spec/types.js +33 -0
- package/dist/usd/spec/types.js.map +1 -0
- package/dist/usd/utils/index.d.ts +6 -0
- package/dist/usd/utils/index.d.ts.map +1 -0
- package/dist/usd/utils/index.js +6 -0
- package/dist/usd/utils/index.js.map +1 -0
- package/dist/usd/utils/merge.d.ts +29 -0
- package/dist/usd/utils/merge.d.ts.map +1 -0
- package/dist/usd/utils/merge.js +92 -0
- package/dist/usd/utils/merge.js.map +1 -0
- package/dist/usd/utils/refs.d.ts +46 -0
- package/dist/usd/utils/refs.d.ts.map +1 -0
- package/dist/usd/utils/refs.js +102 -0
- package/dist/usd/utils/refs.js.map +1 -0
- package/dist/usd/validator/errors.d.ts +66 -0
- package/dist/usd/validator/errors.d.ts.map +1 -0
- package/dist/usd/validator/errors.js +132 -0
- package/dist/usd/validator/errors.js.map +1 -0
- package/dist/usd/validator/index.d.ts +68 -0
- package/dist/usd/validator/index.d.ts.map +1 -0
- package/dist/usd/validator/index.js +92 -0
- package/dist/usd/validator/index.js.map +1 -0
- package/dist/usd/validator/schema.d.ts +905 -0
- package/dist/usd/validator/schema.d.ts.map +1 -0
- package/dist/usd/validator/schema.js +539 -0
- package/dist/usd/validator/schema.js.map +1 -0
- package/dist/usd/validator/semantic.d.ts +15 -0
- package/dist/usd/validator/semantic.d.ts.map +1 -0
- package/dist/usd/validator/semantic.js +452 -0
- package/dist/usd/validator/semantic.js.map +1 -0
- package/dist/utils/content-codecs.d.ts +14 -0
- package/dist/utils/content-codecs.d.ts.map +1 -0
- package/dist/utils/content-codecs.js +201 -0
- package/dist/utils/content-codecs.js.map +1 -0
- package/dist/utils/header-metadata.d.ts +6 -0
- package/dist/utils/header-metadata.d.ts.map +1 -0
- package/dist/utils/header-metadata.js +78 -0
- package/dist/utils/header-metadata.js.map +1 -0
- package/dist/utils/id/alphabets.d.ts +68 -0
- package/dist/utils/id/alphabets.d.ts.map +1 -0
- package/dist/utils/id/alphabets.js +90 -0
- package/dist/utils/id/alphabets.js.map +1 -0
- package/dist/utils/id/entropy.d.ts +45 -0
- package/dist/utils/id/entropy.d.ts.map +1 -0
- package/dist/utils/id/entropy.js +154 -0
- package/dist/utils/id/entropy.js.map +1 -0
- package/dist/utils/id/index.d.ts +15 -0
- package/dist/utils/id/index.d.ts.map +1 -0
- package/dist/utils/id/index.js +13 -0
- package/dist/utils/id/index.js.map +1 -0
- package/dist/utils/id/sid.d.ts +86 -0
- package/dist/utils/id/sid.d.ts.map +1 -0
- package/dist/utils/id/sid.js +109 -0
- package/dist/utils/id/sid.js.map +1 -0
- package/dist/utils/index.d.ts +7 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +8 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/logger.d.ts +15 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +36 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/validation/adapters/ajv.d.ts +59 -0
- package/dist/validation/adapters/ajv.d.ts.map +1 -0
- package/dist/validation/adapters/ajv.js +136 -0
- package/dist/validation/adapters/ajv.js.map +1 -0
- package/dist/validation/adapters/fastest.d.ts +52 -0
- package/dist/validation/adapters/fastest.d.ts.map +1 -0
- package/dist/validation/adapters/fastest.js +215 -0
- package/dist/validation/adapters/fastest.js.map +1 -0
- package/dist/validation/adapters/index.d.ts +19 -0
- package/dist/validation/adapters/index.d.ts.map +1 -0
- package/dist/validation/adapters/index.js +19 -0
- package/dist/validation/adapters/index.js.map +1 -0
- package/dist/validation/adapters/joi.d.ts +51 -0
- package/dist/validation/adapters/joi.d.ts.map +1 -0
- package/dist/validation/adapters/joi.js +267 -0
- package/dist/validation/adapters/joi.js.map +1 -0
- package/dist/validation/adapters/yup.d.ts +53 -0
- package/dist/validation/adapters/yup.d.ts.map +1 -0
- package/dist/validation/adapters/yup.js +267 -0
- package/dist/validation/adapters/yup.js.map +1 -0
- package/dist/validation/adapters/zod.d.ts +52 -0
- package/dist/validation/adapters/zod.d.ts.map +1 -0
- package/dist/validation/adapters/zod.js +107 -0
- package/dist/validation/adapters/zod.js.map +1 -0
- package/dist/validation/index.d.ts +26 -0
- package/dist/validation/index.d.ts.map +1 -0
- package/dist/validation/index.js +48 -0
- package/dist/validation/index.js.map +1 -0
- package/dist/validation/multi-validator.int.test.d.ts +7 -0
- package/dist/validation/multi-validator.int.test.d.ts.map +1 -0
- package/dist/validation/multi-validator.int.test.js +808 -0
- package/dist/validation/multi-validator.int.test.js.map +1 -0
- package/dist/validation/schema.d.ts +150 -0
- package/dist/validation/schema.d.ts.map +1 -0
- package/dist/validation/schema.int.test.d.ts +5 -0
- package/dist/validation/schema.int.test.d.ts.map +1 -0
- package/dist/validation/schema.int.test.js +340 -0
- package/dist/validation/schema.int.test.js.map +1 -0
- package/dist/validation/schema.js +271 -0
- package/dist/validation/schema.js.map +1 -0
- package/dist/validation/types.d.ts +72 -0
- package/dist/validation/types.d.ts.map +1 -0
- package/dist/validation/types.js +14 -0
- package/dist/validation/types.js.map +1 -0
- package/package.json +222 -0
|
@@ -0,0 +1,3065 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* USD Documentation UI HTML Builder
|
|
3
|
+
*
|
|
4
|
+
* Generates the complete HTML for the USD documentation UI.
|
|
5
|
+
* This module assembles all parts: HTML structure, CSS styles, and embedded JavaScript.
|
|
6
|
+
*
|
|
7
|
+
* Security Note: The embedded JavaScript uses innerHTML for rendering documentation
|
|
8
|
+
* from trusted server-generated spec data. User-provided strings are escaped via esc().
|
|
9
|
+
* This is safe because:
|
|
10
|
+
* 1. The spec object is generated by our code (not user input)
|
|
11
|
+
* 2. All user-visible text is escaped before rendering
|
|
12
|
+
* 3. JSON data is escaped for script embedding to prevent XSS
|
|
13
|
+
*/
|
|
14
|
+
import { generateStyles } from './styles.js';
|
|
15
|
+
import { escapeHtml, escapeJsonForScript, generateHeroBackgroundCSS } from './utils.js';
|
|
16
|
+
/**
|
|
17
|
+
* Generate HTML for USD documentation UI
|
|
18
|
+
*/
|
|
19
|
+
export function generateUIHTML(options) {
|
|
20
|
+
const { doc, basePath: _basePath, ui, tagGroups } = options;
|
|
21
|
+
const theme = ui?.theme ?? 'auto';
|
|
22
|
+
const primaryColor = ui?.primaryColor ?? '#6366f1';
|
|
23
|
+
const logo = ui?.logo;
|
|
24
|
+
const favicon = ui?.favicon;
|
|
25
|
+
const title = doc.info.title;
|
|
26
|
+
const hero = ui?.hero;
|
|
27
|
+
const sidebar = ui?.sidebar;
|
|
28
|
+
// Escape data for embedding in script tag (prevents XSS)
|
|
29
|
+
const escapedSpec = escapeJsonForScript(doc);
|
|
30
|
+
const escapedTagGroups = escapeJsonForScript(tagGroups ?? []);
|
|
31
|
+
const escapedHero = escapeJsonForScript(hero ?? null);
|
|
32
|
+
const escapedSidebar = escapeJsonForScript(sidebar ?? {});
|
|
33
|
+
// Generate hero background CSS
|
|
34
|
+
const heroBackgroundCSS = generateHeroBackgroundCSS(primaryColor, hero?.background, hero?.backgroundImage);
|
|
35
|
+
// Generate CSS
|
|
36
|
+
const styles = generateStyles({ primaryColor, heroBackgroundCSS });
|
|
37
|
+
// Generate HTML
|
|
38
|
+
return `<!DOCTYPE html>
|
|
39
|
+
<html lang="en" data-theme="${theme}">
|
|
40
|
+
<head>
|
|
41
|
+
<meta charset="UTF-8">
|
|
42
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
43
|
+
<title>${escapeHtml(title)}</title>
|
|
44
|
+
${favicon ? `<link rel="icon" href="${escapeHtml(favicon)}">` : ''}
|
|
45
|
+
<style>
|
|
46
|
+
${styles}
|
|
47
|
+
</style>
|
|
48
|
+
</head>
|
|
49
|
+
<body>
|
|
50
|
+
${generateHeroSection(hero, logo, title)}
|
|
51
|
+
${generateAppContainer(logo, title, sidebar)}
|
|
52
|
+
<script>
|
|
53
|
+
${generateClientScript(escapedSpec, escapedTagGroups, escapedHero, escapedSidebar)}
|
|
54
|
+
</script>
|
|
55
|
+
</body>
|
|
56
|
+
</html>`;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Generate hero section HTML
|
|
60
|
+
*/
|
|
61
|
+
function generateHeroSection(hero, logo, title) {
|
|
62
|
+
if (!hero)
|
|
63
|
+
return '';
|
|
64
|
+
const buttonsHtml = hero.buttons && hero.buttons.length > 0
|
|
65
|
+
? `<div class="hero-buttons">
|
|
66
|
+
${hero.buttons.map(btn => `
|
|
67
|
+
<a href="${btn.href || '#docs'}" class="hero-btn ${btn.primary ? 'hero-btn-primary' : 'hero-btn-secondary'}">
|
|
68
|
+
${escapeHtml(btn.text)}
|
|
69
|
+
</a>
|
|
70
|
+
`).join('')}
|
|
71
|
+
</div>`
|
|
72
|
+
: '';
|
|
73
|
+
const quickLinksHtml = hero.quickLinks && hero.quickLinks.length > 0
|
|
74
|
+
? `<div class="hero-quicklinks">
|
|
75
|
+
${hero.quickLinks.map(link => `
|
|
76
|
+
<a href="${escapeHtml(link.href)}" class="hero-quicklink">
|
|
77
|
+
${link.icon ? `<div class="hero-quicklink-icon">${escapeHtml(link.icon)}</div>` : ''}
|
|
78
|
+
<div class="hero-quicklink-title">${escapeHtml(link.title)}</div>
|
|
79
|
+
${link.description ? `<div class="hero-quicklink-desc">${escapeHtml(link.description)}</div>` : ''}
|
|
80
|
+
</a>
|
|
81
|
+
`).join('')}
|
|
82
|
+
</div>`
|
|
83
|
+
: '';
|
|
84
|
+
return `
|
|
85
|
+
<header class="hero">
|
|
86
|
+
<div class="hero-content">
|
|
87
|
+
${logo ? `<img class="hero-logo" src="${escapeHtml(logo)}" alt="Logo">` : ''}
|
|
88
|
+
<h1 class="hero-title">${escapeHtml(hero.title || title)}</h1>
|
|
89
|
+
${hero.tagline ? `<p class="hero-tagline">${escapeHtml(hero.tagline)}</p>` : ''}
|
|
90
|
+
${buttonsHtml}
|
|
91
|
+
${quickLinksHtml}
|
|
92
|
+
</div>
|
|
93
|
+
</header>
|
|
94
|
+
`;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Generate app container HTML
|
|
98
|
+
*/
|
|
99
|
+
function generateAppContainer(logo, title, sidebar) {
|
|
100
|
+
return `
|
|
101
|
+
<div class="app-container" id="docs">
|
|
102
|
+
<aside class="sidebar">
|
|
103
|
+
<div class="sidebar-header">
|
|
104
|
+
<div class="sidebar-logo">
|
|
105
|
+
${logo ? `<img src="${escapeHtml(logo)}" alt="Logo">` : ''}
|
|
106
|
+
<h1>${escapeHtml(title)}</h1>
|
|
107
|
+
</div>
|
|
108
|
+
${sidebar?.search !== false ? `
|
|
109
|
+
<div class="sidebar-search">
|
|
110
|
+
<input type="text" id="searchInput" placeholder="Search endpoints...">
|
|
111
|
+
</div>
|
|
112
|
+
` : ''}
|
|
113
|
+
</div>
|
|
114
|
+
<div class="protocol-tabs" id="protocolTabs"></div>
|
|
115
|
+
<nav class="sidebar-nav" id="sidebarNav"></nav>
|
|
116
|
+
</aside>
|
|
117
|
+
<main class="main" id="mainContent"></main>
|
|
118
|
+
</div>
|
|
119
|
+
`;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Generate client-side JavaScript
|
|
123
|
+
* This is embedded in the HTML and handles all UI interactions
|
|
124
|
+
*/
|
|
125
|
+
function generateClientScript(escapedSpec, escapedTagGroups, escapedHero, escapedSidebar) {
|
|
126
|
+
return `
|
|
127
|
+
// Trusted data from server
|
|
128
|
+
const spec = ${escapedSpec};
|
|
129
|
+
const tagGroups = ${escapedTagGroups};
|
|
130
|
+
const heroConfig = ${escapedHero};
|
|
131
|
+
const sidebarConfig = ${escapedSidebar};
|
|
132
|
+
|
|
133
|
+
// Helper to escape text for display
|
|
134
|
+
function esc(str) {
|
|
135
|
+
if (!str) return '';
|
|
136
|
+
const div = document.createElement('div');
|
|
137
|
+
div.textContent = str;
|
|
138
|
+
return div.innerHTML;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// Simple markdown parser for descriptions
|
|
142
|
+
function parseMarkdown(md) {
|
|
143
|
+
if (!md) return '';
|
|
144
|
+
let html = esc(md);
|
|
145
|
+
var tick = String.fromCharCode(96); // backtick character
|
|
146
|
+
|
|
147
|
+
// Code blocks (must be before inline code)
|
|
148
|
+
var codeBlockRe = new RegExp(tick + tick + tick + '(\\\\w*)\\\\n([\\\\s\\\\S]*?)' + tick + tick + tick, 'g');
|
|
149
|
+
html = html.replace(codeBlockRe, function(m, lang, code) {
|
|
150
|
+
return '<pre class="md-code-block"><code class="language-' + (lang || 'text') + '">' + code.trim() + '</code></pre>';
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
// Inline code
|
|
154
|
+
var inlineCodeRe = new RegExp(tick + '([^' + tick + ']+)' + tick, 'g');
|
|
155
|
+
html = html.replace(inlineCodeRe, '<code class="md-inline-code">$1</code>');
|
|
156
|
+
|
|
157
|
+
// Headers (## -> h2, ### -> h3, etc.)
|
|
158
|
+
html = html.replace(/^#### (.+)$/gm, '<h4 class="md-h4">$1</h4>');
|
|
159
|
+
html = html.replace(/^### (.+)$/gm, '<h3 class="md-h3">$1</h3>');
|
|
160
|
+
html = html.replace(/^## (.+)$/gm, '<h2 class="md-h2">$1</h2>');
|
|
161
|
+
|
|
162
|
+
// Bold
|
|
163
|
+
html = html.replace(/\\*\\*([^*]+)\\*\\*/g, '<strong>$1</strong>');
|
|
164
|
+
|
|
165
|
+
// Italic
|
|
166
|
+
html = html.replace(/\\*([^*]+)\\*/g, '<em>$1</em>');
|
|
167
|
+
|
|
168
|
+
// Tables
|
|
169
|
+
html = html.replace(/^\\|(.+)\\|$/gm, function(match, content) {
|
|
170
|
+
const cells = content.split('|').map(c => c.trim());
|
|
171
|
+
// Check if it's a separator row
|
|
172
|
+
if (cells.every(c => /^[-:]+$/.test(c))) {
|
|
173
|
+
return ''; // Skip separator
|
|
174
|
+
}
|
|
175
|
+
const isHeader = match.indexOf('---') === -1 && html.indexOf(match) < html.indexOf('|---');
|
|
176
|
+
const cellTag = 'td';
|
|
177
|
+
return '<tr>' + cells.map(c => '<' + cellTag + '>' + c + '</' + cellTag + '>').join('') + '</tr>';
|
|
178
|
+
});
|
|
179
|
+
// Wrap table rows in table
|
|
180
|
+
html = html.replace(/(<tr>[\\s\\S]*?<\\/tr>)+/g, function(rows) {
|
|
181
|
+
return '<table class="md-table">' + rows + '</table>';
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
// Lists
|
|
185
|
+
html = html.replace(/^- (.+)$/gm, '<li>$1</li>');
|
|
186
|
+
html = html.replace(/(<li>[\\s\\S]*?<\\/li>)+/g, function(items) {
|
|
187
|
+
return '<ul class="md-list">' + items + '</ul>';
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
// Paragraphs (double newlines)
|
|
191
|
+
html = html.replace(/\\n\\n+/g, '</p><p class="md-p">');
|
|
192
|
+
html = '<p class="md-p">' + html + '</p>';
|
|
193
|
+
|
|
194
|
+
// Clean up empty paragraphs
|
|
195
|
+
html = html.replace(/<p class="md-p"><\\/p>/g, '');
|
|
196
|
+
html = html.replace(/<p class="md-p">(\\s*<(?:h[234]|ul|table|pre)[^>]*>)/g, '$1');
|
|
197
|
+
html = html.replace(/(<\\/(?:h[234]|ul|table|pre)>)\\s*<\\/p>/g, '$1');
|
|
198
|
+
|
|
199
|
+
return html;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
// Detect protocols with counts
|
|
203
|
+
const protocolData = {};
|
|
204
|
+
const xUsd = spec['x-usd'] || {};
|
|
205
|
+
const wsSpec = xUsd.websocket;
|
|
206
|
+
const streamsSpec = xUsd.streams;
|
|
207
|
+
const jsonrpcSpec = xUsd.jsonrpc;
|
|
208
|
+
const grpcSpec = xUsd.grpc;
|
|
209
|
+
const tcpSpec = xUsd.tcp;
|
|
210
|
+
const udpSpec = xUsd.udp;
|
|
211
|
+
if (spec.paths) {
|
|
212
|
+
let count = 0;
|
|
213
|
+
Object.values(spec.paths).forEach(methods => {
|
|
214
|
+
Object.keys(methods).forEach(m => {
|
|
215
|
+
if (['get','post','put','patch','delete'].includes(m)) count++;
|
|
216
|
+
});
|
|
217
|
+
});
|
|
218
|
+
if (count > 0) protocolData.http = count;
|
|
219
|
+
}
|
|
220
|
+
if (wsSpec?.channels) {
|
|
221
|
+
protocolData.websocket = Object.keys(wsSpec.channels).length;
|
|
222
|
+
}
|
|
223
|
+
if (streamsSpec?.endpoints) {
|
|
224
|
+
protocolData.streams = Object.keys(streamsSpec.endpoints).length;
|
|
225
|
+
}
|
|
226
|
+
if (jsonrpcSpec?.methods) {
|
|
227
|
+
protocolData.jsonrpc = Object.keys(jsonrpcSpec.methods).length;
|
|
228
|
+
}
|
|
229
|
+
if (grpcSpec?.services) {
|
|
230
|
+
let count = 0;
|
|
231
|
+
Object.values(grpcSpec.services).forEach(s => {
|
|
232
|
+
count += Object.keys(s.methods || {}).length;
|
|
233
|
+
});
|
|
234
|
+
if (count > 0) protocolData.grpc = count;
|
|
235
|
+
}
|
|
236
|
+
if (tcpSpec?.servers) {
|
|
237
|
+
protocolData.tcp = Object.keys(tcpSpec.servers).length;
|
|
238
|
+
}
|
|
239
|
+
if (udpSpec?.endpoints) {
|
|
240
|
+
protocolData.udp = Object.keys(udpSpec.endpoints).length;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
const protocols = Object.keys(protocolData);
|
|
244
|
+
let activeProtocol = protocols[0] || 'http';
|
|
245
|
+
let searchQuery = '';
|
|
246
|
+
|
|
247
|
+
// Search functionality
|
|
248
|
+
const searchInput = document.getElementById('searchInput');
|
|
249
|
+
if (searchInput) {
|
|
250
|
+
searchInput.addEventListener('input', (e) => {
|
|
251
|
+
searchQuery = e.target.value.toLowerCase();
|
|
252
|
+
renderSidebar();
|
|
253
|
+
renderContent();
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
function renderProtocolTabs() {
|
|
258
|
+
const container = document.getElementById('protocolTabs');
|
|
259
|
+
container.textContent = '';
|
|
260
|
+
protocols.forEach(p => {
|
|
261
|
+
const btn = document.createElement('button');
|
|
262
|
+
btn.className = 'protocol-tab' + (p === activeProtocol ? ' active' : '');
|
|
263
|
+
const label = p.charAt(0).toUpperCase() + p.slice(1);
|
|
264
|
+
const count = protocolData[p];
|
|
265
|
+
btn.innerHTML = label + (sidebarConfig.showCounts !== false ? '<span class="count">' + count + '</span>' : '');
|
|
266
|
+
btn.onclick = () => setProtocol(p);
|
|
267
|
+
container.appendChild(btn);
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
function setProtocol(protocol) {
|
|
272
|
+
activeProtocol = protocol;
|
|
273
|
+
renderProtocolTabs();
|
|
274
|
+
renderSidebar();
|
|
275
|
+
renderContent();
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
function renderSidebar() {
|
|
279
|
+
const nav = document.getElementById('sidebarNav');
|
|
280
|
+
nav.textContent = '';
|
|
281
|
+
|
|
282
|
+
// Add Introduction link if there's a description (and not searching)
|
|
283
|
+
if (!searchQuery && spec.info && spec.info.description) {
|
|
284
|
+
const introLink = document.createElement('div');
|
|
285
|
+
introLink.className = 'nav-item nav-item-intro';
|
|
286
|
+
introLink.innerHTML = '<span class="nav-item-icon">📖</span><span class="nav-item-text">Introduction</span>';
|
|
287
|
+
introLink.onclick = () => {
|
|
288
|
+
const el = document.getElementById('introduction');
|
|
289
|
+
if (el) el.scrollIntoView({ behavior: 'smooth', block: 'start' });
|
|
290
|
+
};
|
|
291
|
+
nav.appendChild(introLink);
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
// Get endpoints for current protocol
|
|
295
|
+
const endpoints = getEndpointsForProtocol(activeProtocol);
|
|
296
|
+
|
|
297
|
+
// Filter by search
|
|
298
|
+
const filtered = searchQuery
|
|
299
|
+
? endpoints.filter(e =>
|
|
300
|
+
e.path.toLowerCase().includes(searchQuery) ||
|
|
301
|
+
(e.summary || '').toLowerCase().includes(searchQuery) ||
|
|
302
|
+
(e.description || '').toLowerCase().includes(searchQuery)
|
|
303
|
+
)
|
|
304
|
+
: endpoints;
|
|
305
|
+
|
|
306
|
+
// Group by tags
|
|
307
|
+
const tagMap = new Map();
|
|
308
|
+
const untagged = [];
|
|
309
|
+
|
|
310
|
+
filtered.forEach(ep => {
|
|
311
|
+
const tags = ep.tags || ['Other'];
|
|
312
|
+
if (tags.length === 0) {
|
|
313
|
+
untagged.push(ep);
|
|
314
|
+
} else {
|
|
315
|
+
tags.forEach(tag => {
|
|
316
|
+
if (!tagMap.has(tag)) tagMap.set(tag, []);
|
|
317
|
+
tagMap.get(tag).push(ep);
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
});
|
|
321
|
+
|
|
322
|
+
// Use tagGroups if defined, otherwise auto-group by tags (sorted, Other last)
|
|
323
|
+
const sortedTags = Array.from(tagMap.keys()).sort((a, b) => {
|
|
324
|
+
if (a === 'Other') return 1;
|
|
325
|
+
if (b === 'Other') return -1;
|
|
326
|
+
return a.localeCompare(b);
|
|
327
|
+
});
|
|
328
|
+
const groups = tagGroups.length > 0 ? tagGroups : sortedTags.map(name => ({
|
|
329
|
+
name,
|
|
330
|
+
tags: [name],
|
|
331
|
+
expanded: sidebarConfig.expandAll !== false
|
|
332
|
+
}));
|
|
333
|
+
|
|
334
|
+
groups.forEach((group, idx) => {
|
|
335
|
+
const groupEndpoints = [];
|
|
336
|
+
group.tags.forEach(tag => {
|
|
337
|
+
const eps = tagMap.get(tag) || [];
|
|
338
|
+
groupEndpoints.push(...eps);
|
|
339
|
+
});
|
|
340
|
+
|
|
341
|
+
if (groupEndpoints.length === 0) return;
|
|
342
|
+
|
|
343
|
+
const groupEl = document.createElement('div');
|
|
344
|
+
groupEl.className = 'tag-group' + (group.expanded === false ? ' collapsed' : '');
|
|
345
|
+
|
|
346
|
+
const header = document.createElement('div');
|
|
347
|
+
header.className = 'tag-group-header';
|
|
348
|
+
header.innerHTML = '<span class="tag-group-arrow">▼</span>' +
|
|
349
|
+
esc(group.name) +
|
|
350
|
+
'<span class="tag-group-count">' + groupEndpoints.length + '</span>';
|
|
351
|
+
header.onclick = () => groupEl.classList.toggle('collapsed');
|
|
352
|
+
|
|
353
|
+
const items = document.createElement('div');
|
|
354
|
+
items.className = 'tag-group-items';
|
|
355
|
+
items.style.maxHeight = group.expanded === false ? '0' : (groupEndpoints.length * 50) + 'px';
|
|
356
|
+
|
|
357
|
+
groupEndpoints.forEach(ep => {
|
|
358
|
+
const item = document.createElement('div');
|
|
359
|
+
item.className = 'nav-item';
|
|
360
|
+
item.innerHTML = '<span class="nav-item-method ' + getMethodClass(ep.method) + '">' +
|
|
361
|
+
esc(ep.method) + '</span><span class="nav-item-path">' + esc(ep.path) + '</span>';
|
|
362
|
+
item.onclick = (e) => {
|
|
363
|
+
e.stopPropagation();
|
|
364
|
+
scrollToEndpoint(ep.id);
|
|
365
|
+
};
|
|
366
|
+
items.appendChild(item);
|
|
367
|
+
});
|
|
368
|
+
|
|
369
|
+
groupEl.appendChild(header);
|
|
370
|
+
groupEl.appendChild(items);
|
|
371
|
+
nav.appendChild(groupEl);
|
|
372
|
+
});
|
|
373
|
+
|
|
374
|
+
// Add untagged if any
|
|
375
|
+
if (untagged.length > 0) {
|
|
376
|
+
const groupEl = document.createElement('div');
|
|
377
|
+
groupEl.className = 'tag-group';
|
|
378
|
+
|
|
379
|
+
const header = document.createElement('div');
|
|
380
|
+
header.className = 'tag-group-header';
|
|
381
|
+
header.innerHTML = '<span class="tag-group-arrow">▼</span>Other<span class="tag-group-count">' + untagged.length + '</span>';
|
|
382
|
+
header.onclick = () => groupEl.classList.toggle('collapsed');
|
|
383
|
+
|
|
384
|
+
const items = document.createElement('div');
|
|
385
|
+
items.className = 'tag-group-items';
|
|
386
|
+
items.style.maxHeight = (untagged.length * 50) + 'px';
|
|
387
|
+
|
|
388
|
+
untagged.forEach(ep => {
|
|
389
|
+
const item = document.createElement('div');
|
|
390
|
+
item.className = 'nav-item';
|
|
391
|
+
item.innerHTML = '<span class="nav-item-method ' + getMethodClass(ep.method) + '">' +
|
|
392
|
+
esc(ep.method) + '</span><span class="nav-item-path">' + esc(ep.path) + '</span>';
|
|
393
|
+
item.onclick = (e) => {
|
|
394
|
+
e.stopPropagation();
|
|
395
|
+
scrollToEndpoint(ep.id);
|
|
396
|
+
};
|
|
397
|
+
items.appendChild(item);
|
|
398
|
+
});
|
|
399
|
+
|
|
400
|
+
groupEl.appendChild(header);
|
|
401
|
+
groupEl.appendChild(items);
|
|
402
|
+
nav.appendChild(groupEl);
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
function getMethodClass(method) {
|
|
407
|
+
const m = method.toLowerCase();
|
|
408
|
+
if (m === 'get') return 'method-get';
|
|
409
|
+
if (m === 'post') return 'method-post';
|
|
410
|
+
if (m === 'put') return 'method-put';
|
|
411
|
+
if (m === 'patch') return 'method-patch';
|
|
412
|
+
if (m === 'delete') return 'method-delete';
|
|
413
|
+
if (m === 'ws' || m === 'websocket') return 'method-ws';
|
|
414
|
+
if (m === 'stream' || m === 'sse') return 'method-stream';
|
|
415
|
+
if (m === 'rpc') return 'method-rpc';
|
|
416
|
+
if (m === 'grpc' || m === 'unary') return 'method-grpc';
|
|
417
|
+
return 'method-post';
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
function getEndpointsForProtocol(protocol) {
|
|
421
|
+
const endpoints = [];
|
|
422
|
+
let id = 0;
|
|
423
|
+
|
|
424
|
+
if (protocol === 'http' && spec.paths) {
|
|
425
|
+
Object.entries(spec.paths).forEach(([path, methods]) => {
|
|
426
|
+
Object.entries(methods).forEach(([method, op]) => {
|
|
427
|
+
if (!['get','post','put','patch','delete'].includes(method)) return;
|
|
428
|
+
endpoints.push({
|
|
429
|
+
id: 'ep-' + (id++),
|
|
430
|
+
path,
|
|
431
|
+
method: method.toUpperCase(),
|
|
432
|
+
summary: op.summary,
|
|
433
|
+
description: op.description,
|
|
434
|
+
tags: op.tags || [],
|
|
435
|
+
data: op
|
|
436
|
+
});
|
|
437
|
+
});
|
|
438
|
+
});
|
|
439
|
+
} else if (protocol === 'websocket' && wsSpec?.channels) {
|
|
440
|
+
Object.entries(wsSpec.channels).forEach(([name, channel]) => {
|
|
441
|
+
endpoints.push({
|
|
442
|
+
id: 'ep-' + (id++),
|
|
443
|
+
path: name,
|
|
444
|
+
method: 'WS',
|
|
445
|
+
summary: channel.description,
|
|
446
|
+
tags: channel.tags || [],
|
|
447
|
+
data: channel
|
|
448
|
+
});
|
|
449
|
+
});
|
|
450
|
+
} else if (protocol === 'streams' && streamsSpec?.endpoints) {
|
|
451
|
+
Object.entries(streamsSpec.endpoints).forEach(([name, endpoint]) => {
|
|
452
|
+
endpoints.push({
|
|
453
|
+
id: 'ep-' + (id++),
|
|
454
|
+
path: name,
|
|
455
|
+
method: endpoint.direction || 'STREAM',
|
|
456
|
+
summary: endpoint.description,
|
|
457
|
+
tags: endpoint.tags || [],
|
|
458
|
+
data: endpoint
|
|
459
|
+
});
|
|
460
|
+
});
|
|
461
|
+
} else if (protocol === 'jsonrpc' && jsonrpcSpec?.methods) {
|
|
462
|
+
Object.entries(jsonrpcSpec.methods).forEach(([name, method]) => {
|
|
463
|
+
endpoints.push({
|
|
464
|
+
id: 'ep-' + (id++),
|
|
465
|
+
path: name,
|
|
466
|
+
method: 'RPC',
|
|
467
|
+
summary: method.description,
|
|
468
|
+
tags: method.tags || [],
|
|
469
|
+
data: method
|
|
470
|
+
});
|
|
471
|
+
});
|
|
472
|
+
} else if (protocol === 'grpc' && grpcSpec?.services) {
|
|
473
|
+
Object.entries(grpcSpec.services).forEach(([serviceName, service]) => {
|
|
474
|
+
Object.entries(service.methods || {}).forEach(([methodName, method]) => {
|
|
475
|
+
const type = getGrpcMethodType(method);
|
|
476
|
+
endpoints.push({
|
|
477
|
+
id: 'ep-' + (id++),
|
|
478
|
+
path: serviceName + '/' + methodName,
|
|
479
|
+
method: type.toUpperCase(),
|
|
480
|
+
summary: method.description,
|
|
481
|
+
tags: service.tags || [],
|
|
482
|
+
data: { service, method, serviceName, methodName }
|
|
483
|
+
});
|
|
484
|
+
});
|
|
485
|
+
});
|
|
486
|
+
} else if (protocol === 'tcp' && tcpSpec?.servers) {
|
|
487
|
+
Object.entries(tcpSpec.servers).forEach(([name, server]) => {
|
|
488
|
+
endpoints.push({
|
|
489
|
+
id: 'ep-' + (id++),
|
|
490
|
+
path: name,
|
|
491
|
+
method: 'TCP',
|
|
492
|
+
summary: server.description,
|
|
493
|
+
tags: server.tags || [],
|
|
494
|
+
data: server
|
|
495
|
+
});
|
|
496
|
+
});
|
|
497
|
+
} else if (protocol === 'udp' && udpSpec?.endpoints) {
|
|
498
|
+
Object.entries(udpSpec.endpoints).forEach(([name, endpoint]) => {
|
|
499
|
+
endpoints.push({
|
|
500
|
+
id: 'ep-' + (id++),
|
|
501
|
+
path: name,
|
|
502
|
+
method: 'UDP',
|
|
503
|
+
summary: endpoint.description,
|
|
504
|
+
tags: endpoint.tags || [],
|
|
505
|
+
data: endpoint
|
|
506
|
+
});
|
|
507
|
+
});
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
return endpoints;
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
function scrollToEndpoint(id) {
|
|
514
|
+
const el = document.getElementById(id);
|
|
515
|
+
if (el) {
|
|
516
|
+
el.scrollIntoView({ behavior: 'smooth', block: 'start' });
|
|
517
|
+
el.classList.add('expanded');
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
function renderContent() {
|
|
522
|
+
const main = document.getElementById('mainContent');
|
|
523
|
+
main.textContent = '';
|
|
524
|
+
|
|
525
|
+
// Render API introduction/description (only when not searching)
|
|
526
|
+
if (!searchQuery && spec.info && spec.info.description) {
|
|
527
|
+
const intro = document.createElement('div');
|
|
528
|
+
intro.className = 'intro-section';
|
|
529
|
+
intro.id = 'introduction';
|
|
530
|
+
|
|
531
|
+
const content = document.createElement('div');
|
|
532
|
+
content.className = 'markdown-content';
|
|
533
|
+
content.innerHTML = parseMarkdown(spec.info.description);
|
|
534
|
+
intro.appendChild(content);
|
|
535
|
+
main.appendChild(intro);
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
const endpoints = getEndpointsForProtocol(activeProtocol);
|
|
539
|
+
const filtered = searchQuery
|
|
540
|
+
? endpoints.filter(e =>
|
|
541
|
+
e.path.toLowerCase().includes(searchQuery) ||
|
|
542
|
+
(e.summary || '').toLowerCase().includes(searchQuery)
|
|
543
|
+
)
|
|
544
|
+
: endpoints;
|
|
545
|
+
|
|
546
|
+
if (filtered.length === 0) {
|
|
547
|
+
const empty = document.createElement('div');
|
|
548
|
+
empty.className = 'section';
|
|
549
|
+
empty.innerHTML = '<p style="color: var(--text-muted);">No endpoints found' +
|
|
550
|
+
(searchQuery ? ' matching "' + esc(searchQuery) + '"' : '') + '</p>';
|
|
551
|
+
main.appendChild(empty);
|
|
552
|
+
return;
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
// Group by tags for display
|
|
556
|
+
const tagMap = new Map();
|
|
557
|
+
filtered.forEach(ep => {
|
|
558
|
+
const tag = (ep.tags && ep.tags[0]) || 'Endpoints';
|
|
559
|
+
if (!tagMap.has(tag)) tagMap.set(tag, []);
|
|
560
|
+
tagMap.get(tag).push(ep);
|
|
561
|
+
});
|
|
562
|
+
|
|
563
|
+
tagMap.forEach((eps, tag) => {
|
|
564
|
+
const section = document.createElement('div');
|
|
565
|
+
section.className = 'section';
|
|
566
|
+
|
|
567
|
+
const title = document.createElement('h2');
|
|
568
|
+
title.className = 'section-title';
|
|
569
|
+
title.textContent = tag;
|
|
570
|
+
section.appendChild(title);
|
|
571
|
+
|
|
572
|
+
// Find tag description from spec
|
|
573
|
+
const tagDef = (spec.tags || []).find(t => t.name === tag);
|
|
574
|
+
if (tagDef?.description) {
|
|
575
|
+
const desc = document.createElement('p');
|
|
576
|
+
desc.className = 'section-desc';
|
|
577
|
+
desc.textContent = tagDef.description;
|
|
578
|
+
section.appendChild(desc);
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
eps.forEach(ep => {
|
|
582
|
+
const card = createEndpointCard(ep);
|
|
583
|
+
section.appendChild(card);
|
|
584
|
+
});
|
|
585
|
+
|
|
586
|
+
main.appendChild(section);
|
|
587
|
+
});
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
// ========== TRY IT OUT ==========
|
|
591
|
+
|
|
592
|
+
function renderTryItOut(ep) {
|
|
593
|
+
const container = document.createElement('div');
|
|
594
|
+
container.className = 'try-it-out';
|
|
595
|
+
|
|
596
|
+
// Header
|
|
597
|
+
const header = document.createElement('div');
|
|
598
|
+
header.className = 'try-it-header';
|
|
599
|
+
header.innerHTML = '<span class="try-it-title">Try it out</span>' +
|
|
600
|
+
'<button class="try-it-toggle" type="button">▼</button>';
|
|
601
|
+
header.onclick = () => container.classList.toggle('collapsed');
|
|
602
|
+
container.appendChild(header);
|
|
603
|
+
|
|
604
|
+
// Form content
|
|
605
|
+
const form = document.createElement('div');
|
|
606
|
+
form.className = 'try-it-form';
|
|
607
|
+
|
|
608
|
+
const data = ep.data || {};
|
|
609
|
+
const params = data.parameters || [];
|
|
610
|
+
const baseUrl = (spec.servers && spec.servers[0]?.url) || 'http://localhost:3000';
|
|
611
|
+
|
|
612
|
+
// Server URL
|
|
613
|
+
const urlGroup = document.createElement('div');
|
|
614
|
+
urlGroup.className = 'try-it-group';
|
|
615
|
+
urlGroup.innerHTML = '<label class="try-it-label">Server</label>' +
|
|
616
|
+
'<input type="text" class="try-it-input try-it-server" value="' + esc(baseUrl) + '">';
|
|
617
|
+
form.appendChild(urlGroup);
|
|
618
|
+
|
|
619
|
+
// Path parameters
|
|
620
|
+
const pathParams = params.filter(p => p.in === 'path');
|
|
621
|
+
if (pathParams.length > 0) {
|
|
622
|
+
const section = document.createElement('div');
|
|
623
|
+
section.className = 'try-it-section';
|
|
624
|
+
section.innerHTML = '<div class="try-it-section-title">Path Parameters</div>';
|
|
625
|
+
pathParams.forEach(p => {
|
|
626
|
+
const group = document.createElement('div');
|
|
627
|
+
group.className = 'try-it-group';
|
|
628
|
+
const schema = p.schema || {};
|
|
629
|
+
const placeholder = schema.example || schema.default || p.name;
|
|
630
|
+
group.innerHTML = '<label class="try-it-label">' + esc(p.name) +
|
|
631
|
+
(p.required ? ' <span class="try-it-required">*</span>' : '') + '</label>' +
|
|
632
|
+
'<input type="text" class="try-it-input try-it-path-param" ' +
|
|
633
|
+
'data-name="' + esc(p.name) + '" placeholder="' + esc(String(placeholder)) + '"' +
|
|
634
|
+
(schema.default !== undefined ? ' value="' + esc(String(schema.default)) + '"' : '') + '>';
|
|
635
|
+
section.appendChild(group);
|
|
636
|
+
});
|
|
637
|
+
form.appendChild(section);
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
// Query parameters
|
|
641
|
+
const queryParams = params.filter(p => p.in === 'query');
|
|
642
|
+
if (queryParams.length > 0) {
|
|
643
|
+
const section = document.createElement('div');
|
|
644
|
+
section.className = 'try-it-section';
|
|
645
|
+
section.innerHTML = '<div class="try-it-section-title">Query Parameters</div>';
|
|
646
|
+
queryParams.forEach(p => {
|
|
647
|
+
const group = document.createElement('div');
|
|
648
|
+
group.className = 'try-it-group';
|
|
649
|
+
const schema = p.schema || {};
|
|
650
|
+
const placeholder = schema.example || schema.default || '';
|
|
651
|
+
group.innerHTML = '<label class="try-it-label">' + esc(p.name) +
|
|
652
|
+
(p.required ? ' <span class="try-it-required">*</span>' : '') + '</label>' +
|
|
653
|
+
'<input type="text" class="try-it-input try-it-query-param" ' +
|
|
654
|
+
'data-name="' + esc(p.name) + '" placeholder="' + esc(String(placeholder)) + '"' +
|
|
655
|
+
(schema.default !== undefined ? ' value="' + esc(String(schema.default)) + '"' : '') + '>';
|
|
656
|
+
section.appendChild(group);
|
|
657
|
+
});
|
|
658
|
+
form.appendChild(section);
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
// Header parameters
|
|
662
|
+
const headerParams = params.filter(p => p.in === 'header');
|
|
663
|
+
if (headerParams.length > 0) {
|
|
664
|
+
const section = document.createElement('div');
|
|
665
|
+
section.className = 'try-it-section';
|
|
666
|
+
section.innerHTML = '<div class="try-it-section-title">Headers</div>';
|
|
667
|
+
headerParams.forEach(p => {
|
|
668
|
+
const group = document.createElement('div');
|
|
669
|
+
group.className = 'try-it-group';
|
|
670
|
+
const schema = p.schema || {};
|
|
671
|
+
group.innerHTML = '<label class="try-it-label">' + esc(p.name) +
|
|
672
|
+
(p.required ? ' <span class="try-it-required">*</span>' : '') + '</label>' +
|
|
673
|
+
'<input type="text" class="try-it-input try-it-header-param" ' +
|
|
674
|
+
'data-name="' + esc(p.name) + '"' +
|
|
675
|
+
(schema.default !== undefined ? ' value="' + esc(String(schema.default)) + '"' : '') + '>';
|
|
676
|
+
section.appendChild(group);
|
|
677
|
+
});
|
|
678
|
+
form.appendChild(section);
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
// Request body
|
|
682
|
+
if (data.requestBody) {
|
|
683
|
+
const section = document.createElement('div');
|
|
684
|
+
section.className = 'try-it-section';
|
|
685
|
+
section.innerHTML = '<div class="try-it-section-title">Request Body</div>';
|
|
686
|
+
|
|
687
|
+
const content = data.requestBody.content || {};
|
|
688
|
+
const contentType = Object.keys(content)[0] || 'application/json';
|
|
689
|
+
const mediaType = content[contentType] || {};
|
|
690
|
+
|
|
691
|
+
// Build example from schema
|
|
692
|
+
let exampleBody = {};
|
|
693
|
+
if (mediaType.schema) {
|
|
694
|
+
exampleBody = buildExampleFromSchema(mediaType.schema) || {};
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
const textarea = document.createElement('textarea');
|
|
698
|
+
textarea.className = 'try-it-body';
|
|
699
|
+
textarea.placeholder = 'Request body (JSON)';
|
|
700
|
+
textarea.value = JSON.stringify(exampleBody, null, 2);
|
|
701
|
+
section.appendChild(textarea);
|
|
702
|
+
form.appendChild(section);
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
// Send button
|
|
706
|
+
const actions = document.createElement('div');
|
|
707
|
+
actions.className = 'try-it-actions';
|
|
708
|
+
const sendBtn = document.createElement('button');
|
|
709
|
+
sendBtn.type = 'button';
|
|
710
|
+
sendBtn.className = 'try-it-send';
|
|
711
|
+
sendBtn.textContent = 'Send Request';
|
|
712
|
+
actions.appendChild(sendBtn);
|
|
713
|
+
form.appendChild(actions);
|
|
714
|
+
|
|
715
|
+
// Response area
|
|
716
|
+
const responseArea = document.createElement('div');
|
|
717
|
+
responseArea.className = 'try-it-response';
|
|
718
|
+
responseArea.style.display = 'none';
|
|
719
|
+
form.appendChild(responseArea);
|
|
720
|
+
|
|
721
|
+
container.appendChild(form);
|
|
722
|
+
|
|
723
|
+
// Handle send
|
|
724
|
+
sendBtn.onclick = async () => {
|
|
725
|
+
sendBtn.disabled = true;
|
|
726
|
+
sendBtn.textContent = 'Sending...';
|
|
727
|
+
responseArea.style.display = 'block';
|
|
728
|
+
responseArea.innerHTML = '<div class="try-it-loading">Loading...</div>';
|
|
729
|
+
|
|
730
|
+
try {
|
|
731
|
+
// Build URL
|
|
732
|
+
const serverInput = form.querySelector('.try-it-server');
|
|
733
|
+
let url = serverInput.value + ep.path;
|
|
734
|
+
|
|
735
|
+
// Replace path params
|
|
736
|
+
form.querySelectorAll('.try-it-path-param').forEach(input => {
|
|
737
|
+
const name = input.getAttribute('data-name');
|
|
738
|
+
const value = input.value || input.placeholder;
|
|
739
|
+
url = url.replace('{' + name + '}', encodeURIComponent(value));
|
|
740
|
+
url = url.replace(':' + name, encodeURIComponent(value));
|
|
741
|
+
});
|
|
742
|
+
|
|
743
|
+
// Add query params
|
|
744
|
+
const queryParts = [];
|
|
745
|
+
form.querySelectorAll('.try-it-query-param').forEach(input => {
|
|
746
|
+
const name = input.getAttribute('data-name');
|
|
747
|
+
const value = input.value;
|
|
748
|
+
if (value) {
|
|
749
|
+
queryParts.push(encodeURIComponent(name) + '=' + encodeURIComponent(value));
|
|
750
|
+
}
|
|
751
|
+
});
|
|
752
|
+
if (queryParts.length > 0) {
|
|
753
|
+
url += '?' + queryParts.join('&');
|
|
754
|
+
}
|
|
755
|
+
|
|
756
|
+
// Build headers
|
|
757
|
+
const headers = {};
|
|
758
|
+
form.querySelectorAll('.try-it-header-param').forEach(input => {
|
|
759
|
+
const name = input.getAttribute('data-name');
|
|
760
|
+
const value = input.value;
|
|
761
|
+
if (value) {
|
|
762
|
+
headers[name] = value;
|
|
763
|
+
}
|
|
764
|
+
});
|
|
765
|
+
|
|
766
|
+
// Build request options
|
|
767
|
+
const options = {
|
|
768
|
+
method: ep.method.toUpperCase(),
|
|
769
|
+
headers: headers,
|
|
770
|
+
};
|
|
771
|
+
|
|
772
|
+
// Add body for POST/PUT/PATCH
|
|
773
|
+
if (['POST', 'PUT', 'PATCH'].includes(options.method)) {
|
|
774
|
+
const bodyTextarea = form.querySelector('.try-it-body');
|
|
775
|
+
if (bodyTextarea && bodyTextarea.value) {
|
|
776
|
+
options.headers['Content-Type'] = 'application/json';
|
|
777
|
+
options.body = bodyTextarea.value;
|
|
778
|
+
}
|
|
779
|
+
}
|
|
780
|
+
|
|
781
|
+
// Send request
|
|
782
|
+
const startTime = performance.now();
|
|
783
|
+
const response = await fetch(url, options);
|
|
784
|
+
const endTime = performance.now();
|
|
785
|
+
const duration = Math.round(endTime - startTime);
|
|
786
|
+
|
|
787
|
+
// Get response body
|
|
788
|
+
let responseBody = '';
|
|
789
|
+
const contentType = response.headers.get('content-type') || '';
|
|
790
|
+
if (contentType.includes('application/json')) {
|
|
791
|
+
try {
|
|
792
|
+
const json = await response.json();
|
|
793
|
+
responseBody = JSON.stringify(json, null, 2);
|
|
794
|
+
} catch (e) {
|
|
795
|
+
responseBody = await response.text();
|
|
796
|
+
}
|
|
797
|
+
} else {
|
|
798
|
+
responseBody = await response.text();
|
|
799
|
+
}
|
|
800
|
+
|
|
801
|
+
// Display response
|
|
802
|
+
const statusClass = response.ok ? 'status-2xx' :
|
|
803
|
+
response.status >= 400 && response.status < 500 ? 'status-4xx' : 'status-5xx';
|
|
804
|
+
|
|
805
|
+
responseArea.innerHTML =
|
|
806
|
+
'<div class="try-it-response-header">' +
|
|
807
|
+
'<span class="try-it-response-status ' + statusClass + '">' + response.status + ' ' + response.statusText + '</span>' +
|
|
808
|
+
'<span class="try-it-response-time">' + duration + 'ms</span>' +
|
|
809
|
+
'</div>' +
|
|
810
|
+
'<div class="try-it-response-headers">' +
|
|
811
|
+
'<div class="try-it-section-title">Response Headers</div>' +
|
|
812
|
+
'<pre class="try-it-response-headers-pre">' + formatResponseHeaders(response) + '</pre>' +
|
|
813
|
+
'</div>' +
|
|
814
|
+
'<div class="try-it-response-body">' +
|
|
815
|
+
'<div class="try-it-section-title">Response Body</div>' +
|
|
816
|
+
'<pre class="sample-json"><code>' + (contentType.includes('json') ? syntaxHighlightJSON(responseBody) : esc(responseBody)) + '</code></pre>' +
|
|
817
|
+
'</div>';
|
|
818
|
+
} catch (error) {
|
|
819
|
+
responseArea.innerHTML =
|
|
820
|
+
'<div class="try-it-error">' +
|
|
821
|
+
'<strong>Error:</strong> ' + esc(error.message) +
|
|
822
|
+
'</div>';
|
|
823
|
+
} finally {
|
|
824
|
+
sendBtn.disabled = false;
|
|
825
|
+
sendBtn.textContent = 'Send Request';
|
|
826
|
+
}
|
|
827
|
+
};
|
|
828
|
+
|
|
829
|
+
return container;
|
|
830
|
+
}
|
|
831
|
+
|
|
832
|
+
function formatResponseHeaders(response) {
|
|
833
|
+
const lines = [];
|
|
834
|
+
response.headers.forEach((value, key) => {
|
|
835
|
+
lines.push(esc(key) + ': ' + esc(value));
|
|
836
|
+
});
|
|
837
|
+
return lines.join('\\n');
|
|
838
|
+
}
|
|
839
|
+
|
|
840
|
+
// ========== TRY IT OUT WEBSOCKET ==========
|
|
841
|
+
|
|
842
|
+
function renderTryItOutWebSocket(ep) {
|
|
843
|
+
const container = document.createElement('div');
|
|
844
|
+
container.className = 'try-it-out try-it-ws';
|
|
845
|
+
|
|
846
|
+
// Header
|
|
847
|
+
const header = document.createElement('div');
|
|
848
|
+
header.className = 'try-it-header';
|
|
849
|
+
header.innerHTML = '<span class="try-it-title">WebSocket Console</span>' +
|
|
850
|
+
'<button class="try-it-toggle" type="button">▼</button>';
|
|
851
|
+
header.onclick = () => container.classList.toggle('collapsed');
|
|
852
|
+
container.appendChild(header);
|
|
853
|
+
|
|
854
|
+
// Form content
|
|
855
|
+
const form = document.createElement('div');
|
|
856
|
+
form.className = 'try-it-form';
|
|
857
|
+
|
|
858
|
+
const data = ep.data || {};
|
|
859
|
+
const baseUrl = (spec.servers && spec.servers[0]?.url) || 'http://localhost:3000';
|
|
860
|
+
const wsUrl = baseUrl.replace(/^http/, 'ws') + (ep.path || '/' + ep.id);
|
|
861
|
+
|
|
862
|
+
// WebSocket URL
|
|
863
|
+
const urlGroup = document.createElement('div');
|
|
864
|
+
urlGroup.className = 'try-it-group';
|
|
865
|
+
urlGroup.innerHTML = '<label class="try-it-label">WebSocket URL</label>' +
|
|
866
|
+
'<input type="text" class="try-it-input try-it-ws-url" value="' + esc(wsUrl) + '">';
|
|
867
|
+
form.appendChild(urlGroup);
|
|
868
|
+
|
|
869
|
+
// Connection parameters (if any)
|
|
870
|
+
if (data.parameters && Object.keys(data.parameters).length > 0) {
|
|
871
|
+
const section = document.createElement('div');
|
|
872
|
+
section.className = 'try-it-section';
|
|
873
|
+
section.innerHTML = '<div class="try-it-section-title">Parameters</div>';
|
|
874
|
+
Object.entries(data.parameters).forEach(([name, param]) => {
|
|
875
|
+
const group = document.createElement('div');
|
|
876
|
+
group.className = 'try-it-group';
|
|
877
|
+
group.innerHTML = '<label class="try-it-label">' + esc(name) +
|
|
878
|
+
(param.required ? ' <span class="try-it-required">*</span>' : '') + '</label>' +
|
|
879
|
+
'<input type="text" class="try-it-input try-it-ws-param" ' +
|
|
880
|
+
'data-name="' + esc(name) + '" placeholder="' + esc(param.description || '') + '">';
|
|
881
|
+
section.appendChild(group);
|
|
882
|
+
});
|
|
883
|
+
form.appendChild(section);
|
|
884
|
+
}
|
|
885
|
+
|
|
886
|
+
// Message to send
|
|
887
|
+
const msgSection = document.createElement('div');
|
|
888
|
+
msgSection.className = 'try-it-section';
|
|
889
|
+
msgSection.innerHTML = '<div class="try-it-section-title">Send Message</div>';
|
|
890
|
+
|
|
891
|
+
// Build example message from subscribe/publish schema
|
|
892
|
+
let exampleMsg = {};
|
|
893
|
+
if (data.subscribe?.message?.payload) {
|
|
894
|
+
exampleMsg = buildExampleFromSchema(data.subscribe.message.payload);
|
|
895
|
+
} else if (data.publish?.message?.payload) {
|
|
896
|
+
exampleMsg = buildExampleFromSchema(data.publish.message.payload);
|
|
897
|
+
}
|
|
898
|
+
|
|
899
|
+
const textarea = document.createElement('textarea');
|
|
900
|
+
textarea.className = 'try-it-body try-it-ws-message';
|
|
901
|
+
textarea.placeholder = 'Message to send (JSON)';
|
|
902
|
+
textarea.value = JSON.stringify(exampleMsg || {}, null, 2);
|
|
903
|
+
msgSection.appendChild(textarea);
|
|
904
|
+
form.appendChild(msgSection);
|
|
905
|
+
|
|
906
|
+
// Actions
|
|
907
|
+
const actions = document.createElement('div');
|
|
908
|
+
actions.className = 'try-it-actions try-it-ws-actions';
|
|
909
|
+
|
|
910
|
+
const connectBtn = document.createElement('button');
|
|
911
|
+
connectBtn.type = 'button';
|
|
912
|
+
connectBtn.className = 'try-it-send try-it-ws-connect';
|
|
913
|
+
connectBtn.textContent = 'Connect';
|
|
914
|
+
|
|
915
|
+
const sendBtn = document.createElement('button');
|
|
916
|
+
sendBtn.type = 'button';
|
|
917
|
+
sendBtn.className = 'try-it-send try-it-ws-send';
|
|
918
|
+
sendBtn.textContent = 'Send';
|
|
919
|
+
sendBtn.disabled = true;
|
|
920
|
+
sendBtn.style.marginTop = '8px';
|
|
921
|
+
|
|
922
|
+
actions.appendChild(connectBtn);
|
|
923
|
+
actions.appendChild(sendBtn);
|
|
924
|
+
form.appendChild(actions);
|
|
925
|
+
|
|
926
|
+
// Status indicator
|
|
927
|
+
const statusDiv = document.createElement('div');
|
|
928
|
+
statusDiv.className = 'try-it-ws-status';
|
|
929
|
+
statusDiv.innerHTML = '<span class="ws-status-dot"></span><span class="ws-status-text">Disconnected</span>';
|
|
930
|
+
form.appendChild(statusDiv);
|
|
931
|
+
|
|
932
|
+
// Messages log
|
|
933
|
+
const logSection = document.createElement('div');
|
|
934
|
+
logSection.className = 'try-it-section try-it-ws-log-section';
|
|
935
|
+
logSection.style.display = 'none';
|
|
936
|
+
logSection.innerHTML = '<div class="try-it-section-title">Messages <button class="try-it-ws-clear" type="button">Clear</button></div>';
|
|
937
|
+
const log = document.createElement('div');
|
|
938
|
+
log.className = 'try-it-ws-log';
|
|
939
|
+
logSection.appendChild(log);
|
|
940
|
+
form.appendChild(logSection);
|
|
941
|
+
|
|
942
|
+
container.appendChild(form);
|
|
943
|
+
|
|
944
|
+
// WebSocket connection logic
|
|
945
|
+
let ws = null;
|
|
946
|
+
|
|
947
|
+
const updateStatus = (connected) => {
|
|
948
|
+
const dot = statusDiv.querySelector('.ws-status-dot');
|
|
949
|
+
const text = statusDiv.querySelector('.ws-status-text');
|
|
950
|
+
if (connected) {
|
|
951
|
+
dot.classList.add('connected');
|
|
952
|
+
text.textContent = 'Connected';
|
|
953
|
+
connectBtn.textContent = 'Disconnect';
|
|
954
|
+
sendBtn.disabled = false;
|
|
955
|
+
logSection.style.display = 'block';
|
|
956
|
+
} else {
|
|
957
|
+
dot.classList.remove('connected');
|
|
958
|
+
text.textContent = 'Disconnected';
|
|
959
|
+
connectBtn.textContent = 'Connect';
|
|
960
|
+
sendBtn.disabled = true;
|
|
961
|
+
}
|
|
962
|
+
};
|
|
963
|
+
|
|
964
|
+
const addMessage = (type, content) => {
|
|
965
|
+
const msg = document.createElement('div');
|
|
966
|
+
msg.className = 'try-it-ws-msg try-it-ws-msg-' + type;
|
|
967
|
+
const time = new Date().toLocaleTimeString();
|
|
968
|
+
msg.innerHTML = '<span class="ws-msg-time">' + time + '</span>' +
|
|
969
|
+
'<span class="ws-msg-type">' + type + '</span>' +
|
|
970
|
+
'<pre class="ws-msg-content">' + esc(typeof content === 'string' ? content : JSON.stringify(content, null, 2)) + '</pre>';
|
|
971
|
+
log.appendChild(msg);
|
|
972
|
+
log.scrollTop = log.scrollHeight;
|
|
973
|
+
};
|
|
974
|
+
|
|
975
|
+
connectBtn.onclick = () => {
|
|
976
|
+
if (ws && ws.readyState === WebSocket.OPEN) {
|
|
977
|
+
ws.close();
|
|
978
|
+
return;
|
|
979
|
+
}
|
|
980
|
+
|
|
981
|
+
let url = form.querySelector('.try-it-ws-url').value;
|
|
982
|
+
|
|
983
|
+
// Add parameters to URL
|
|
984
|
+
const params = [];
|
|
985
|
+
form.querySelectorAll('.try-it-ws-param').forEach(input => {
|
|
986
|
+
const name = input.getAttribute('data-name');
|
|
987
|
+
const value = input.value;
|
|
988
|
+
if (value) {
|
|
989
|
+
params.push(encodeURIComponent(name) + '=' + encodeURIComponent(value));
|
|
990
|
+
}
|
|
991
|
+
});
|
|
992
|
+
if (params.length > 0) {
|
|
993
|
+
url += (url.includes('?') ? '&' : '?') + params.join('&');
|
|
994
|
+
}
|
|
995
|
+
|
|
996
|
+
try {
|
|
997
|
+
ws = new WebSocket(url);
|
|
998
|
+
|
|
999
|
+
ws.onopen = () => {
|
|
1000
|
+
updateStatus(true);
|
|
1001
|
+
addMessage('system', 'Connected to ' + url);
|
|
1002
|
+
};
|
|
1003
|
+
|
|
1004
|
+
ws.onmessage = (event) => {
|
|
1005
|
+
let data = event.data;
|
|
1006
|
+
try {
|
|
1007
|
+
data = JSON.parse(data);
|
|
1008
|
+
} catch (e) {}
|
|
1009
|
+
addMessage('received', data);
|
|
1010
|
+
};
|
|
1011
|
+
|
|
1012
|
+
ws.onclose = (event) => {
|
|
1013
|
+
updateStatus(false);
|
|
1014
|
+
addMessage('system', 'Disconnected (code: ' + event.code + ')');
|
|
1015
|
+
};
|
|
1016
|
+
|
|
1017
|
+
ws.onerror = () => {
|
|
1018
|
+
addMessage('error', 'Connection error');
|
|
1019
|
+
};
|
|
1020
|
+
} catch (err) {
|
|
1021
|
+
addMessage('error', err.message);
|
|
1022
|
+
}
|
|
1023
|
+
};
|
|
1024
|
+
|
|
1025
|
+
sendBtn.onclick = () => {
|
|
1026
|
+
if (!ws || ws.readyState !== WebSocket.OPEN) return;
|
|
1027
|
+
const message = form.querySelector('.try-it-ws-message').value;
|
|
1028
|
+
ws.send(message);
|
|
1029
|
+
addMessage('sent', message);
|
|
1030
|
+
};
|
|
1031
|
+
|
|
1032
|
+
logSection.querySelector('.try-it-ws-clear').onclick = () => {
|
|
1033
|
+
log.innerHTML = '';
|
|
1034
|
+
};
|
|
1035
|
+
|
|
1036
|
+
return container;
|
|
1037
|
+
}
|
|
1038
|
+
|
|
1039
|
+
// ========== TRY IT OUT STREAMS (SSE/EventSource) ==========
|
|
1040
|
+
|
|
1041
|
+
function renderTryItOutStreams(ep) {
|
|
1042
|
+
const container = document.createElement('div');
|
|
1043
|
+
container.className = 'try-it-out try-it-sse';
|
|
1044
|
+
|
|
1045
|
+
// Header
|
|
1046
|
+
const header = document.createElement('div');
|
|
1047
|
+
header.className = 'try-it-header';
|
|
1048
|
+
header.innerHTML = '<span class="try-it-title">Stream Console</span>' +
|
|
1049
|
+
'<button class="try-it-toggle" type="button">▼</button>';
|
|
1050
|
+
header.onclick = () => container.classList.toggle('collapsed');
|
|
1051
|
+
container.appendChild(header);
|
|
1052
|
+
|
|
1053
|
+
// Form content
|
|
1054
|
+
const form = document.createElement('div');
|
|
1055
|
+
form.className = 'try-it-form';
|
|
1056
|
+
|
|
1057
|
+
const data = ep.data || {};
|
|
1058
|
+
const baseUrl = (spec.servers && spec.servers[0]?.url) || 'http://localhost:3000';
|
|
1059
|
+
const streamUrl = baseUrl + (ep.path || '/' + ep.id);
|
|
1060
|
+
|
|
1061
|
+
// Stream URL
|
|
1062
|
+
const urlGroup = document.createElement('div');
|
|
1063
|
+
urlGroup.className = 'try-it-group';
|
|
1064
|
+
urlGroup.innerHTML = '<label class="try-it-label">Stream URL</label>' +
|
|
1065
|
+
'<input type="text" class="try-it-input try-it-sse-url" value="' + esc(streamUrl) + '">';
|
|
1066
|
+
form.appendChild(urlGroup);
|
|
1067
|
+
|
|
1068
|
+
// Query parameters (if any)
|
|
1069
|
+
if (data.parameters && Object.keys(data.parameters).length > 0) {
|
|
1070
|
+
const section = document.createElement('div');
|
|
1071
|
+
section.className = 'try-it-section';
|
|
1072
|
+
section.innerHTML = '<div class="try-it-section-title">Parameters</div>';
|
|
1073
|
+
Object.entries(data.parameters).forEach(([name, param]) => {
|
|
1074
|
+
const group = document.createElement('div');
|
|
1075
|
+
group.className = 'try-it-group';
|
|
1076
|
+
group.innerHTML = '<label class="try-it-label">' + esc(name) +
|
|
1077
|
+
(param.required ? ' <span class="try-it-required">*</span>' : '') + '</label>' +
|
|
1078
|
+
'<input type="text" class="try-it-input try-it-sse-param" ' +
|
|
1079
|
+
'data-name="' + esc(name) + '" placeholder="' + esc(param.description || '') + '">';
|
|
1080
|
+
section.appendChild(group);
|
|
1081
|
+
});
|
|
1082
|
+
form.appendChild(section);
|
|
1083
|
+
}
|
|
1084
|
+
|
|
1085
|
+
// Actions
|
|
1086
|
+
const actions = document.createElement('div');
|
|
1087
|
+
actions.className = 'try-it-actions try-it-sse-actions';
|
|
1088
|
+
|
|
1089
|
+
const subscribeBtn = document.createElement('button');
|
|
1090
|
+
subscribeBtn.type = 'button';
|
|
1091
|
+
subscribeBtn.className = 'try-it-send try-it-sse-subscribe';
|
|
1092
|
+
subscribeBtn.textContent = 'Subscribe';
|
|
1093
|
+
|
|
1094
|
+
actions.appendChild(subscribeBtn);
|
|
1095
|
+
form.appendChild(actions);
|
|
1096
|
+
|
|
1097
|
+
// Status indicator
|
|
1098
|
+
const statusDiv = document.createElement('div');
|
|
1099
|
+
statusDiv.className = 'try-it-sse-status';
|
|
1100
|
+
statusDiv.innerHTML = '<span class="sse-status-dot"></span><span class="sse-status-text">Disconnected</span>';
|
|
1101
|
+
form.appendChild(statusDiv);
|
|
1102
|
+
|
|
1103
|
+
// Event types filter (shows received event types)
|
|
1104
|
+
const filterSection = document.createElement('div');
|
|
1105
|
+
filterSection.className = 'try-it-section try-it-sse-filter-section';
|
|
1106
|
+
filterSection.style.display = 'none';
|
|
1107
|
+
filterSection.innerHTML = '<div class="try-it-section-title">Event Types</div>' +
|
|
1108
|
+
'<div class="try-it-sse-filter"></div>';
|
|
1109
|
+
form.appendChild(filterSection);
|
|
1110
|
+
|
|
1111
|
+
// Events log
|
|
1112
|
+
const logSection = document.createElement('div');
|
|
1113
|
+
logSection.className = 'try-it-section try-it-sse-log-section';
|
|
1114
|
+
logSection.style.display = 'none';
|
|
1115
|
+
logSection.innerHTML = '<div class="try-it-section-title">Events <span class="sse-event-count"></span><button class="try-it-sse-clear" type="button">Clear</button></div>';
|
|
1116
|
+
const log = document.createElement('div');
|
|
1117
|
+
log.className = 'try-it-sse-log';
|
|
1118
|
+
logSection.appendChild(log);
|
|
1119
|
+
form.appendChild(logSection);
|
|
1120
|
+
|
|
1121
|
+
container.appendChild(form);
|
|
1122
|
+
|
|
1123
|
+
// EventSource connection logic
|
|
1124
|
+
let eventSource = null;
|
|
1125
|
+
let eventCount = 0;
|
|
1126
|
+
const eventTypes = new Set();
|
|
1127
|
+
|
|
1128
|
+
const updateStatus = (connected, connecting) => {
|
|
1129
|
+
const dot = statusDiv.querySelector('.sse-status-dot');
|
|
1130
|
+
const text = statusDiv.querySelector('.sse-status-text');
|
|
1131
|
+
dot.classList.remove('connected', 'connecting');
|
|
1132
|
+
if (connected) {
|
|
1133
|
+
dot.classList.add('connected');
|
|
1134
|
+
text.textContent = 'Connected';
|
|
1135
|
+
subscribeBtn.textContent = 'Unsubscribe';
|
|
1136
|
+
logSection.style.display = 'block';
|
|
1137
|
+
} else if (connecting) {
|
|
1138
|
+
dot.classList.add('connecting');
|
|
1139
|
+
text.textContent = 'Connecting...';
|
|
1140
|
+
subscribeBtn.textContent = 'Cancel';
|
|
1141
|
+
} else {
|
|
1142
|
+
text.textContent = 'Disconnected';
|
|
1143
|
+
subscribeBtn.textContent = 'Subscribe';
|
|
1144
|
+
}
|
|
1145
|
+
};
|
|
1146
|
+
|
|
1147
|
+
const updateEventCount = () => {
|
|
1148
|
+
const countEl = logSection.querySelector('.sse-event-count');
|
|
1149
|
+
countEl.textContent = '(' + eventCount + ')';
|
|
1150
|
+
};
|
|
1151
|
+
|
|
1152
|
+
const addEvent = (type, data, lastEventId) => {
|
|
1153
|
+
eventCount++;
|
|
1154
|
+
updateEventCount();
|
|
1155
|
+
|
|
1156
|
+
// Track event type
|
|
1157
|
+
if (!eventTypes.has(type)) {
|
|
1158
|
+
eventTypes.add(type);
|
|
1159
|
+
updateFilterSection();
|
|
1160
|
+
}
|
|
1161
|
+
|
|
1162
|
+
const event = document.createElement('div');
|
|
1163
|
+
event.className = 'try-it-sse-event' + (type === 'error' ? ' try-it-sse-event-error' : '');
|
|
1164
|
+
event.setAttribute('data-type', type);
|
|
1165
|
+
const time = new Date().toLocaleTimeString();
|
|
1166
|
+
|
|
1167
|
+
let dataStr = data;
|
|
1168
|
+
try {
|
|
1169
|
+
const parsed = JSON.parse(data);
|
|
1170
|
+
dataStr = JSON.stringify(parsed, null, 2);
|
|
1171
|
+
} catch (e) {}
|
|
1172
|
+
|
|
1173
|
+
event.innerHTML = '<div class="sse-event-header">' +
|
|
1174
|
+
'<span class="sse-event-time">' + time + '</span>' +
|
|
1175
|
+
'<span class="sse-event-type">' + esc(type || 'message') + '</span>' +
|
|
1176
|
+
(lastEventId ? '<span class="sse-event-id">id: ' + esc(lastEventId) + '</span>' : '') +
|
|
1177
|
+
'</div>' +
|
|
1178
|
+
'<pre class="sse-event-data">' + esc(dataStr) + '</pre>';
|
|
1179
|
+
log.appendChild(event);
|
|
1180
|
+
log.scrollTop = log.scrollHeight;
|
|
1181
|
+
};
|
|
1182
|
+
|
|
1183
|
+
const updateFilterSection = () => {
|
|
1184
|
+
if (eventTypes.size === 0) {
|
|
1185
|
+
filterSection.style.display = 'none';
|
|
1186
|
+
return;
|
|
1187
|
+
}
|
|
1188
|
+
filterSection.style.display = 'block';
|
|
1189
|
+
const filterContainer = filterSection.querySelector('.try-it-sse-filter');
|
|
1190
|
+
filterContainer.innerHTML = '';
|
|
1191
|
+
eventTypes.forEach(type => {
|
|
1192
|
+
const badge = document.createElement('span');
|
|
1193
|
+
badge.className = 'sse-type-badge';
|
|
1194
|
+
badge.textContent = type || 'message';
|
|
1195
|
+
badge.onclick = () => {
|
|
1196
|
+
badge.classList.toggle('inactive');
|
|
1197
|
+
const show = !badge.classList.contains('inactive');
|
|
1198
|
+
log.querySelectorAll('.try-it-sse-event[data-type="' + type + '"]').forEach(el => {
|
|
1199
|
+
el.style.display = show ? 'block' : 'none';
|
|
1200
|
+
});
|
|
1201
|
+
};
|
|
1202
|
+
filterContainer.appendChild(badge);
|
|
1203
|
+
});
|
|
1204
|
+
};
|
|
1205
|
+
|
|
1206
|
+
subscribeBtn.onclick = () => {
|
|
1207
|
+
if (eventSource) {
|
|
1208
|
+
eventSource.close();
|
|
1209
|
+
eventSource = null;
|
|
1210
|
+
updateStatus(false, false);
|
|
1211
|
+
return;
|
|
1212
|
+
}
|
|
1213
|
+
|
|
1214
|
+
let url = form.querySelector('.try-it-sse-url').value;
|
|
1215
|
+
|
|
1216
|
+
// Add parameters to URL
|
|
1217
|
+
const params = [];
|
|
1218
|
+
form.querySelectorAll('.try-it-sse-param').forEach(input => {
|
|
1219
|
+
const name = input.getAttribute('data-name');
|
|
1220
|
+
const value = input.value;
|
|
1221
|
+
if (value) {
|
|
1222
|
+
params.push(encodeURIComponent(name) + '=' + encodeURIComponent(value));
|
|
1223
|
+
}
|
|
1224
|
+
});
|
|
1225
|
+
if (params.length > 0) {
|
|
1226
|
+
url += (url.includes('?') ? '&' : '?') + params.join('&');
|
|
1227
|
+
}
|
|
1228
|
+
|
|
1229
|
+
updateStatus(false, true);
|
|
1230
|
+
|
|
1231
|
+
try {
|
|
1232
|
+
eventSource = new EventSource(url);
|
|
1233
|
+
|
|
1234
|
+
eventSource.onopen = () => {
|
|
1235
|
+
updateStatus(true, false);
|
|
1236
|
+
addEvent('system', 'Connected to ' + url, null);
|
|
1237
|
+
};
|
|
1238
|
+
|
|
1239
|
+
eventSource.onmessage = (e) => {
|
|
1240
|
+
addEvent('message', e.data, e.lastEventId);
|
|
1241
|
+
};
|
|
1242
|
+
|
|
1243
|
+
// Listen for named events from spec
|
|
1244
|
+
const events = data.events || [];
|
|
1245
|
+
events.forEach(eventName => {
|
|
1246
|
+
eventSource.addEventListener(eventName, (e) => {
|
|
1247
|
+
addEvent(eventName, e.data, e.lastEventId);
|
|
1248
|
+
});
|
|
1249
|
+
});
|
|
1250
|
+
|
|
1251
|
+
eventSource.onerror = () => {
|
|
1252
|
+
if (eventSource.readyState === EventSource.CLOSED) {
|
|
1253
|
+
addEvent('error', 'Connection closed', null);
|
|
1254
|
+
updateStatus(false, false);
|
|
1255
|
+
eventSource = null;
|
|
1256
|
+
} else {
|
|
1257
|
+
addEvent('error', 'Connection error (reconnecting...)', null);
|
|
1258
|
+
}
|
|
1259
|
+
};
|
|
1260
|
+
} catch (err) {
|
|
1261
|
+
addEvent('error', err.message, null);
|
|
1262
|
+
updateStatus(false, false);
|
|
1263
|
+
}
|
|
1264
|
+
};
|
|
1265
|
+
|
|
1266
|
+
logSection.querySelector('.try-it-sse-clear').onclick = () => {
|
|
1267
|
+
log.innerHTML = '';
|
|
1268
|
+
eventCount = 0;
|
|
1269
|
+
updateEventCount();
|
|
1270
|
+
};
|
|
1271
|
+
|
|
1272
|
+
return container;
|
|
1273
|
+
}
|
|
1274
|
+
|
|
1275
|
+
function createEndpointCard(ep) {
|
|
1276
|
+
const section = document.createElement('div');
|
|
1277
|
+
section.className = 'endpoint-section';
|
|
1278
|
+
section.id = ep.id;
|
|
1279
|
+
|
|
1280
|
+
// Header with method + path
|
|
1281
|
+
const header = document.createElement('div');
|
|
1282
|
+
header.className = 'endpoint-header';
|
|
1283
|
+
|
|
1284
|
+
const methodPath = document.createElement('div');
|
|
1285
|
+
methodPath.className = 'endpoint-method-path';
|
|
1286
|
+
|
|
1287
|
+
const badge = document.createElement('span');
|
|
1288
|
+
badge.className = 'badge badge-' + ep.method.toLowerCase();
|
|
1289
|
+
badge.textContent = ep.method;
|
|
1290
|
+
|
|
1291
|
+
const path = document.createElement('span');
|
|
1292
|
+
path.className = 'endpoint-path';
|
|
1293
|
+
path.textContent = ep.path;
|
|
1294
|
+
|
|
1295
|
+
methodPath.appendChild(badge);
|
|
1296
|
+
methodPath.appendChild(path);
|
|
1297
|
+
header.appendChild(methodPath);
|
|
1298
|
+
|
|
1299
|
+
section.appendChild(header);
|
|
1300
|
+
|
|
1301
|
+
// Title (operation summary)
|
|
1302
|
+
if (ep.summary) {
|
|
1303
|
+
const title = document.createElement('h3');
|
|
1304
|
+
title.className = 'endpoint-title';
|
|
1305
|
+
title.textContent = ep.summary;
|
|
1306
|
+
section.appendChild(title);
|
|
1307
|
+
}
|
|
1308
|
+
|
|
1309
|
+
// Description if available (rendered as markdown)
|
|
1310
|
+
const opData = ep.data;
|
|
1311
|
+
if (opData?.description && opData.description !== ep.summary) {
|
|
1312
|
+
const desc = document.createElement('div');
|
|
1313
|
+
desc.className = 'endpoint-description markdown-content';
|
|
1314
|
+
desc.innerHTML = parseMarkdown(opData.description);
|
|
1315
|
+
section.appendChild(desc);
|
|
1316
|
+
}
|
|
1317
|
+
|
|
1318
|
+
// Two-column content layout
|
|
1319
|
+
const content = document.createElement('div');
|
|
1320
|
+
content.className = 'endpoint-content';
|
|
1321
|
+
|
|
1322
|
+
const leftCol = document.createElement('div');
|
|
1323
|
+
leftCol.className = 'endpoint-left';
|
|
1324
|
+
|
|
1325
|
+
const rightCol = document.createElement('div');
|
|
1326
|
+
rightCol.className = 'endpoint-right';
|
|
1327
|
+
|
|
1328
|
+
// Render details into left column
|
|
1329
|
+
leftCol.appendChild(renderEndpointDetails(ep));
|
|
1330
|
+
|
|
1331
|
+
// Render right column content (Request + Response samples)
|
|
1332
|
+
rightCol.appendChild(renderRightPanelContent(ep));
|
|
1333
|
+
|
|
1334
|
+
content.appendChild(leftCol);
|
|
1335
|
+
content.appendChild(rightCol);
|
|
1336
|
+
section.appendChild(content);
|
|
1337
|
+
|
|
1338
|
+
return section;
|
|
1339
|
+
}
|
|
1340
|
+
|
|
1341
|
+
// ========== RIGHT PANEL CONTENT (Request + Response Samples) ==========
|
|
1342
|
+
|
|
1343
|
+
function renderRightPanelContent(ep) {
|
|
1344
|
+
const container = document.createElement('div');
|
|
1345
|
+
container.className = 'right-panel-content';
|
|
1346
|
+
|
|
1347
|
+
if (activeProtocol === 'http') {
|
|
1348
|
+
// Try It Out section
|
|
1349
|
+
const tryItSection = document.createElement('div');
|
|
1350
|
+
tryItSection.className = 'right-section try-it-section';
|
|
1351
|
+
tryItSection.appendChild(renderTryItOut(ep));
|
|
1352
|
+
container.appendChild(tryItSection);
|
|
1353
|
+
|
|
1354
|
+
// Request section
|
|
1355
|
+
const requestSection = document.createElement('div');
|
|
1356
|
+
requestSection.className = 'right-section request-section';
|
|
1357
|
+
|
|
1358
|
+
const requestHeader = document.createElement('div');
|
|
1359
|
+
requestHeader.className = 'right-section-header';
|
|
1360
|
+
requestHeader.textContent = 'Request samples';
|
|
1361
|
+
requestSection.appendChild(requestHeader);
|
|
1362
|
+
|
|
1363
|
+
// Add curl example
|
|
1364
|
+
requestSection.appendChild(renderCodeExample(ep));
|
|
1365
|
+
container.appendChild(requestSection);
|
|
1366
|
+
|
|
1367
|
+
// Response samples section
|
|
1368
|
+
const data = ep.data || {};
|
|
1369
|
+
const responses = data.responses || {};
|
|
1370
|
+
const statusCodes = Object.keys(responses).sort();
|
|
1371
|
+
|
|
1372
|
+
if (statusCodes.length > 0) {
|
|
1373
|
+
const responseSection = document.createElement('div');
|
|
1374
|
+
responseSection.className = 'right-section response-samples-section';
|
|
1375
|
+
|
|
1376
|
+
const responseHeader = document.createElement('div');
|
|
1377
|
+
responseHeader.className = 'right-section-header';
|
|
1378
|
+
responseHeader.textContent = 'Response samples';
|
|
1379
|
+
responseSection.appendChild(responseHeader);
|
|
1380
|
+
|
|
1381
|
+
// Tabs for status codes
|
|
1382
|
+
const tabsContainer = document.createElement('div');
|
|
1383
|
+
tabsContainer.className = 'sample-tabs';
|
|
1384
|
+
|
|
1385
|
+
const contentContainer = document.createElement('div');
|
|
1386
|
+
contentContainer.className = 'sample-contents';
|
|
1387
|
+
|
|
1388
|
+
statusCodes.forEach((status, idx) => {
|
|
1389
|
+
// Tab button
|
|
1390
|
+
const tab = document.createElement('button');
|
|
1391
|
+
tab.className = 'sample-tab' + (idx === 0 ? ' active' : '');
|
|
1392
|
+
const statusClass = status.startsWith('2') ? 'status-2xx' :
|
|
1393
|
+
status.startsWith('4') ? 'status-4xx' :
|
|
1394
|
+
status.startsWith('5') ? 'status-5xx' : '';
|
|
1395
|
+
tab.innerHTML = '<span class="tab-status ' + statusClass + '">' + esc(status) + '</span>';
|
|
1396
|
+
tab.onclick = () => {
|
|
1397
|
+
// Remove active from all tabs
|
|
1398
|
+
tabsContainer.querySelectorAll('.sample-tab').forEach(t => t.classList.remove('active'));
|
|
1399
|
+
tab.classList.add('active');
|
|
1400
|
+
// Show corresponding content
|
|
1401
|
+
contentContainer.querySelectorAll('.sample-content').forEach((c, i) => {
|
|
1402
|
+
c.style.display = i === idx ? 'block' : 'none';
|
|
1403
|
+
});
|
|
1404
|
+
};
|
|
1405
|
+
tabsContainer.appendChild(tab);
|
|
1406
|
+
|
|
1407
|
+
// Content for this status
|
|
1408
|
+
const content = document.createElement('div');
|
|
1409
|
+
content.className = 'sample-content';
|
|
1410
|
+
content.style.display = idx === 0 ? 'block' : 'none';
|
|
1411
|
+
|
|
1412
|
+
const response = responses[status];
|
|
1413
|
+
const respContent = response.content || {};
|
|
1414
|
+
const contentType = Object.keys(respContent)[0];
|
|
1415
|
+
|
|
1416
|
+
if (contentType && respContent[contentType]) {
|
|
1417
|
+
const mediaType = respContent[contentType];
|
|
1418
|
+
let example = null;
|
|
1419
|
+
|
|
1420
|
+
// Try to get example from various places
|
|
1421
|
+
if (mediaType.example) {
|
|
1422
|
+
example = mediaType.example;
|
|
1423
|
+
} else if (mediaType.examples) {
|
|
1424
|
+
const firstExKey = Object.keys(mediaType.examples)[0];
|
|
1425
|
+
if (firstExKey && mediaType.examples[firstExKey]) {
|
|
1426
|
+
example = mediaType.examples[firstExKey].value;
|
|
1427
|
+
}
|
|
1428
|
+
} else if (mediaType.schema) {
|
|
1429
|
+
// Build example from schema
|
|
1430
|
+
example = buildExampleFromSchema(mediaType.schema);
|
|
1431
|
+
}
|
|
1432
|
+
|
|
1433
|
+
if (example !== null) {
|
|
1434
|
+
const pre = document.createElement('pre');
|
|
1435
|
+
pre.className = 'sample-json';
|
|
1436
|
+
const code = document.createElement('code');
|
|
1437
|
+
code.innerHTML = syntaxHighlightJSON(JSON.stringify(example, null, 2));
|
|
1438
|
+
pre.appendChild(code);
|
|
1439
|
+
content.appendChild(pre);
|
|
1440
|
+
} else {
|
|
1441
|
+
const noExample = document.createElement('div');
|
|
1442
|
+
noExample.className = 'no-example';
|
|
1443
|
+
noExample.textContent = 'No example available';
|
|
1444
|
+
content.appendChild(noExample);
|
|
1445
|
+
}
|
|
1446
|
+
} else {
|
|
1447
|
+
// No content, just description
|
|
1448
|
+
const desc = document.createElement('div');
|
|
1449
|
+
desc.className = 'response-desc-only';
|
|
1450
|
+
desc.textContent = response.description || 'No content';
|
|
1451
|
+
content.appendChild(desc);
|
|
1452
|
+
}
|
|
1453
|
+
|
|
1454
|
+
contentContainer.appendChild(content);
|
|
1455
|
+
});
|
|
1456
|
+
|
|
1457
|
+
responseSection.appendChild(tabsContainer);
|
|
1458
|
+
responseSection.appendChild(contentContainer);
|
|
1459
|
+
container.appendChild(responseSection);
|
|
1460
|
+
}
|
|
1461
|
+
} else if (activeProtocol === 'websocket') {
|
|
1462
|
+
// WebSocket Try It Out
|
|
1463
|
+
const tryItSection = document.createElement('div');
|
|
1464
|
+
tryItSection.className = 'right-section try-it-section';
|
|
1465
|
+
tryItSection.appendChild(renderTryItOutWebSocket(ep));
|
|
1466
|
+
container.appendChild(tryItSection);
|
|
1467
|
+
|
|
1468
|
+
// Request samples (wscat)
|
|
1469
|
+
const requestSection = document.createElement('div');
|
|
1470
|
+
requestSection.className = 'right-section request-section';
|
|
1471
|
+
const requestHeader = document.createElement('div');
|
|
1472
|
+
requestHeader.className = 'right-section-header';
|
|
1473
|
+
requestHeader.textContent = 'Request samples';
|
|
1474
|
+
requestSection.appendChild(requestHeader);
|
|
1475
|
+
requestSection.appendChild(renderCodeExampleWebSocket(ep));
|
|
1476
|
+
container.appendChild(requestSection);
|
|
1477
|
+
} else if (activeProtocol === 'streams') {
|
|
1478
|
+
// Streams (SSE) Try It Out
|
|
1479
|
+
const tryItSection = document.createElement('div');
|
|
1480
|
+
tryItSection.className = 'right-section try-it-section';
|
|
1481
|
+
tryItSection.appendChild(renderTryItOutStreams(ep));
|
|
1482
|
+
container.appendChild(tryItSection);
|
|
1483
|
+
|
|
1484
|
+
// Request samples (curl, EventSource)
|
|
1485
|
+
const requestSection = document.createElement('div');
|
|
1486
|
+
requestSection.className = 'right-section request-section';
|
|
1487
|
+
const requestHeader = document.createElement('div');
|
|
1488
|
+
requestHeader.className = 'right-section-header';
|
|
1489
|
+
requestHeader.textContent = 'Request samples';
|
|
1490
|
+
requestSection.appendChild(requestHeader);
|
|
1491
|
+
requestSection.appendChild(renderCodeExampleStreams(ep));
|
|
1492
|
+
container.appendChild(requestSection);
|
|
1493
|
+
} else {
|
|
1494
|
+
// For other protocols, just show basic code example
|
|
1495
|
+
container.appendChild(renderCodeExample(ep));
|
|
1496
|
+
}
|
|
1497
|
+
|
|
1498
|
+
return container;
|
|
1499
|
+
}
|
|
1500
|
+
|
|
1501
|
+
// WebSocket code examples (wscat, etc.)
|
|
1502
|
+
function renderCodeExampleWebSocket(ep) {
|
|
1503
|
+
const container = document.createElement('div');
|
|
1504
|
+
container.className = 'code-example';
|
|
1505
|
+
|
|
1506
|
+
const baseUrl = (spec.servers && spec.servers[0]?.url) || 'http://localhost:3000';
|
|
1507
|
+
const wsUrl = baseUrl.replace(/^http/, 'ws') + (ep.path || '/' + ep.id);
|
|
1508
|
+
|
|
1509
|
+
// Language tabs
|
|
1510
|
+
const languages = ['wscat', 'javascript', 'python'];
|
|
1511
|
+
const tabs = document.createElement('div');
|
|
1512
|
+
tabs.className = 'code-tabs';
|
|
1513
|
+
|
|
1514
|
+
const contents = document.createElement('div');
|
|
1515
|
+
contents.className = 'code-contents';
|
|
1516
|
+
|
|
1517
|
+
languages.forEach((lang, i) => {
|
|
1518
|
+
// Tab button
|
|
1519
|
+
const tab = document.createElement('button');
|
|
1520
|
+
tab.className = 'code-tab' + (i === 0 ? ' active' : '');
|
|
1521
|
+
tab.textContent = lang === 'wscat' ? 'wscat' : lang === 'javascript' ? 'JavaScript' : 'Python';
|
|
1522
|
+
tab.onclick = () => {
|
|
1523
|
+
tabs.querySelectorAll('.code-tab').forEach(t => t.classList.remove('active'));
|
|
1524
|
+
tab.classList.add('active');
|
|
1525
|
+
contents.querySelectorAll('.code-content').forEach(c => c.classList.remove('active'));
|
|
1526
|
+
contents.querySelector('.code-content[data-lang="' + lang + '"]').classList.add('active');
|
|
1527
|
+
};
|
|
1528
|
+
tabs.appendChild(tab);
|
|
1529
|
+
|
|
1530
|
+
// Content
|
|
1531
|
+
const content = document.createElement('div');
|
|
1532
|
+
content.className = 'code-content' + (i === 0 ? ' active' : '');
|
|
1533
|
+
content.setAttribute('data-lang', lang);
|
|
1534
|
+
|
|
1535
|
+
const pre = document.createElement('pre');
|
|
1536
|
+
const code = document.createElement('code');
|
|
1537
|
+
code.textContent = generateWsCodeSample(lang, wsUrl, ep);
|
|
1538
|
+
pre.appendChild(code);
|
|
1539
|
+
content.appendChild(pre);
|
|
1540
|
+
contents.appendChild(content);
|
|
1541
|
+
});
|
|
1542
|
+
|
|
1543
|
+
container.appendChild(tabs);
|
|
1544
|
+
container.appendChild(contents);
|
|
1545
|
+
|
|
1546
|
+
return container;
|
|
1547
|
+
}
|
|
1548
|
+
|
|
1549
|
+
function generateWsCodeSample(lang, url, ep) {
|
|
1550
|
+
const data = ep.data || {};
|
|
1551
|
+
let exampleMsg = {};
|
|
1552
|
+
if (data.subscribe?.message?.payload) {
|
|
1553
|
+
exampleMsg = buildExampleFromSchema(data.subscribe.message.payload);
|
|
1554
|
+
} else if (data.publish?.message?.payload) {
|
|
1555
|
+
exampleMsg = buildExampleFromSchema(data.publish.message.payload);
|
|
1556
|
+
}
|
|
1557
|
+
const msgStr = JSON.stringify(exampleMsg || {}, null, 2);
|
|
1558
|
+
|
|
1559
|
+
switch (lang) {
|
|
1560
|
+
case 'wscat':
|
|
1561
|
+
return 'wscat -c "' + url + '"\\n\\n# Once connected, send messages:\\n> ' + msgStr.replace(/\\n/g, '');
|
|
1562
|
+
|
|
1563
|
+
case 'javascript':
|
|
1564
|
+
return 'const ws = new WebSocket("' + url + '");\\n\\n' +
|
|
1565
|
+
'ws.onopen = () => {\\n' +
|
|
1566
|
+
' console.log("Connected");\\n' +
|
|
1567
|
+
' ws.send(JSON.stringify(' + msgStr.split('\\n').map((l, i) => i === 0 ? l : ' ' + l).join('\\n') + '));\\n' +
|
|
1568
|
+
'};\\n\\n' +
|
|
1569
|
+
'ws.onmessage = (event) => {\\n' +
|
|
1570
|
+
' console.log("Received:", event.data);\\n' +
|
|
1571
|
+
'};\\n\\n' +
|
|
1572
|
+
'ws.onclose = () => {\\n' +
|
|
1573
|
+
' console.log("Disconnected");\\n' +
|
|
1574
|
+
'};';
|
|
1575
|
+
|
|
1576
|
+
case 'python':
|
|
1577
|
+
return 'import asyncio\\n' +
|
|
1578
|
+
'import websockets\\n\\n' +
|
|
1579
|
+
'async def connect():\\n' +
|
|
1580
|
+
' async with websockets.connect("' + url + '") as ws:\\n' +
|
|
1581
|
+
' await ws.send(\\'\\'\\'\\n' + msgStr + '\\n\\'\\'\\')\\n' +
|
|
1582
|
+
' response = await ws.recv()\\n' +
|
|
1583
|
+
' print(f"Received: {response}")\\n\\n' +
|
|
1584
|
+
'asyncio.run(connect())';
|
|
1585
|
+
|
|
1586
|
+
default:
|
|
1587
|
+
return '// Not implemented';
|
|
1588
|
+
}
|
|
1589
|
+
}
|
|
1590
|
+
|
|
1591
|
+
// Streams (SSE) code examples
|
|
1592
|
+
function renderCodeExampleStreams(ep) {
|
|
1593
|
+
const container = document.createElement('div');
|
|
1594
|
+
container.className = 'code-example';
|
|
1595
|
+
|
|
1596
|
+
const baseUrl = (spec.servers && spec.servers[0]?.url) || 'http://localhost:3000';
|
|
1597
|
+
const streamUrl = baseUrl + (ep.path || '/' + ep.id);
|
|
1598
|
+
|
|
1599
|
+
// Language tabs
|
|
1600
|
+
const languages = ['curl', 'javascript', 'python'];
|
|
1601
|
+
const tabs = document.createElement('div');
|
|
1602
|
+
tabs.className = 'code-tabs';
|
|
1603
|
+
|
|
1604
|
+
const contents = document.createElement('div');
|
|
1605
|
+
contents.className = 'code-contents';
|
|
1606
|
+
|
|
1607
|
+
languages.forEach((lang, i) => {
|
|
1608
|
+
// Tab button
|
|
1609
|
+
const tab = document.createElement('button');
|
|
1610
|
+
tab.className = 'code-tab' + (i === 0 ? ' active' : '');
|
|
1611
|
+
tab.textContent = lang === 'curl' ? 'cURL' : lang === 'javascript' ? 'JavaScript' : 'Python';
|
|
1612
|
+
tab.onclick = () => {
|
|
1613
|
+
tabs.querySelectorAll('.code-tab').forEach(t => t.classList.remove('active'));
|
|
1614
|
+
tab.classList.add('active');
|
|
1615
|
+
contents.querySelectorAll('.code-content').forEach(c => c.classList.remove('active'));
|
|
1616
|
+
contents.querySelector('.code-content[data-lang="' + lang + '"]').classList.add('active');
|
|
1617
|
+
};
|
|
1618
|
+
tabs.appendChild(tab);
|
|
1619
|
+
|
|
1620
|
+
// Content
|
|
1621
|
+
const content = document.createElement('div');
|
|
1622
|
+
content.className = 'code-content' + (i === 0 ? ' active' : '');
|
|
1623
|
+
content.setAttribute('data-lang', lang);
|
|
1624
|
+
|
|
1625
|
+
const pre = document.createElement('pre');
|
|
1626
|
+
const code = document.createElement('code');
|
|
1627
|
+
code.textContent = generateStreamCodeSample(lang, streamUrl, ep);
|
|
1628
|
+
pre.appendChild(code);
|
|
1629
|
+
content.appendChild(pre);
|
|
1630
|
+
contents.appendChild(content);
|
|
1631
|
+
});
|
|
1632
|
+
|
|
1633
|
+
container.appendChild(tabs);
|
|
1634
|
+
container.appendChild(contents);
|
|
1635
|
+
|
|
1636
|
+
return container;
|
|
1637
|
+
}
|
|
1638
|
+
|
|
1639
|
+
function generateStreamCodeSample(lang, url, ep) {
|
|
1640
|
+
switch (lang) {
|
|
1641
|
+
case 'curl':
|
|
1642
|
+
return 'curl -N "' + url + '"\\n\\n# -N disables buffering for streaming output';
|
|
1643
|
+
|
|
1644
|
+
case 'javascript':
|
|
1645
|
+
return 'const eventSource = new EventSource("' + url + '");\\n\\n' +
|
|
1646
|
+
'eventSource.onmessage = (event) => {\\n' +
|
|
1647
|
+
' console.log("Received:", event.data);\\n' +
|
|
1648
|
+
'};\\n\\n' +
|
|
1649
|
+
'eventSource.onerror = (error) => {\\n' +
|
|
1650
|
+
' console.error("Error:", error);\\n' +
|
|
1651
|
+
' eventSource.close();\\n' +
|
|
1652
|
+
'};\\n\\n' +
|
|
1653
|
+
'// To close the connection:\\n' +
|
|
1654
|
+
'// eventSource.close();';
|
|
1655
|
+
|
|
1656
|
+
case 'python':
|
|
1657
|
+
return 'import sseclient\\n' +
|
|
1658
|
+
'import requests\\n\\n' +
|
|
1659
|
+
'response = requests.get("' + url + '", stream=True)\\n' +
|
|
1660
|
+
'client = sseclient.SSEClient(response)\\n\\n' +
|
|
1661
|
+
'for event in client.events():\\n' +
|
|
1662
|
+
' print(f"Event: {event.event}, Data: {event.data}")';
|
|
1663
|
+
|
|
1664
|
+
default:
|
|
1665
|
+
return '// Not implemented';
|
|
1666
|
+
}
|
|
1667
|
+
}
|
|
1668
|
+
|
|
1669
|
+
// JSON syntax highlighting
|
|
1670
|
+
function syntaxHighlightJSON(json) {
|
|
1671
|
+
return json
|
|
1672
|
+
.replace(/&/g, '&')
|
|
1673
|
+
.replace(/</g, '<')
|
|
1674
|
+
.replace(/>/g, '>')
|
|
1675
|
+
.replace(/("(\\\\u[a-zA-Z0-9]{4}|\\\\[^u]|[^\\\\"])*"(\\s*:)?)/g, function(match) {
|
|
1676
|
+
let cls = 'json-string';
|
|
1677
|
+
if (/:$/.test(match)) {
|
|
1678
|
+
cls = 'json-key';
|
|
1679
|
+
match = match.replace(/:$/, '') + ':';
|
|
1680
|
+
}
|
|
1681
|
+
return '<span class="' + cls + '">' + match + '</span>';
|
|
1682
|
+
})
|
|
1683
|
+
.replace(/\\b(true|false|null)\\b/g, '<span class="json-boolean">$1</span>')
|
|
1684
|
+
.replace(/\\b(-?\\d+\\.?\\d*)\\b/g, '<span class="json-number">$1</span>');
|
|
1685
|
+
}
|
|
1686
|
+
|
|
1687
|
+
function renderCodeExample(ep) {
|
|
1688
|
+
const container = document.createElement('div');
|
|
1689
|
+
container.className = 'code-example';
|
|
1690
|
+
|
|
1691
|
+
// Build request details
|
|
1692
|
+
const method = ep.method.toUpperCase();
|
|
1693
|
+
const path = ep.path;
|
|
1694
|
+
const baseUrl = (spec.servers && spec.servers[0]?.url) || 'http://localhost:3000';
|
|
1695
|
+
const fullUrl = baseUrl + path;
|
|
1696
|
+
|
|
1697
|
+
// Get request body if exists
|
|
1698
|
+
let exampleBody = null;
|
|
1699
|
+
const opData = ep.data;
|
|
1700
|
+
if (opData && opData.requestBody && opData.requestBody.content) {
|
|
1701
|
+
const jsonContent = opData.requestBody.content['application/json'];
|
|
1702
|
+
if (jsonContent && jsonContent.schema) {
|
|
1703
|
+
exampleBody = buildExampleFromSchema(jsonContent.schema);
|
|
1704
|
+
}
|
|
1705
|
+
}
|
|
1706
|
+
|
|
1707
|
+
// Language tabs
|
|
1708
|
+
const languages = ['curl', 'typescript', 'python', 'go'];
|
|
1709
|
+
const tabs = document.createElement('div');
|
|
1710
|
+
tabs.className = 'code-tabs';
|
|
1711
|
+
|
|
1712
|
+
const contents = document.createElement('div');
|
|
1713
|
+
contents.className = 'code-contents';
|
|
1714
|
+
|
|
1715
|
+
languages.forEach((lang, i) => {
|
|
1716
|
+
// Tab button
|
|
1717
|
+
const tab = document.createElement('button');
|
|
1718
|
+
tab.className = 'code-tab' + (i === 0 ? ' active' : '');
|
|
1719
|
+
tab.textContent = lang === 'typescript' ? 'TypeScript' : lang === 'curl' ? 'cURL' : lang.charAt(0).toUpperCase() + lang.slice(1);
|
|
1720
|
+
tab.onclick = () => {
|
|
1721
|
+
tabs.querySelectorAll('.code-tab').forEach(t => t.classList.remove('active'));
|
|
1722
|
+
tab.classList.add('active');
|
|
1723
|
+
contents.querySelectorAll('.code-content').forEach(c => c.classList.remove('active'));
|
|
1724
|
+
contents.querySelector('.code-content[data-lang="' + lang + '"]').classList.add('active');
|
|
1725
|
+
};
|
|
1726
|
+
tabs.appendChild(tab);
|
|
1727
|
+
|
|
1728
|
+
// Content
|
|
1729
|
+
const content = document.createElement('div');
|
|
1730
|
+
content.className = 'code-content' + (i === 0 ? ' active' : '');
|
|
1731
|
+
content.setAttribute('data-lang', lang);
|
|
1732
|
+
|
|
1733
|
+
const pre = document.createElement('pre');
|
|
1734
|
+
const code = document.createElement('code');
|
|
1735
|
+
code.textContent = generateCodeSample(lang, method, fullUrl, exampleBody);
|
|
1736
|
+
pre.appendChild(code);
|
|
1737
|
+
content.appendChild(pre);
|
|
1738
|
+
contents.appendChild(content);
|
|
1739
|
+
});
|
|
1740
|
+
|
|
1741
|
+
container.appendChild(tabs);
|
|
1742
|
+
container.appendChild(contents);
|
|
1743
|
+
|
|
1744
|
+
return container;
|
|
1745
|
+
}
|
|
1746
|
+
|
|
1747
|
+
function generateCodeSample(lang, method, url, body) {
|
|
1748
|
+
const hasBody = body && ['POST', 'PUT', 'PATCH'].includes(method);
|
|
1749
|
+
const bodyStr = body ? JSON.stringify(body, null, 2) : '';
|
|
1750
|
+
|
|
1751
|
+
switch (lang) {
|
|
1752
|
+
case 'curl':
|
|
1753
|
+
const curlLines = [];
|
|
1754
|
+
curlLines.push('curl' + (method !== 'GET' ? ' -X ' + method : ''));
|
|
1755
|
+
curlLines.push(' "' + url + '"');
|
|
1756
|
+
if (hasBody) {
|
|
1757
|
+
curlLines.push(' -H "Content-Type: application/json"');
|
|
1758
|
+
curlLines.push(" -d '" + bodyStr + "'");
|
|
1759
|
+
}
|
|
1760
|
+
return curlLines.join(' \\\\\\n');
|
|
1761
|
+
|
|
1762
|
+
case 'typescript':
|
|
1763
|
+
if (hasBody) {
|
|
1764
|
+
return 'const response = await fetch("' + url + '", {\\n' +
|
|
1765
|
+
' method: "' + method + '",\\n' +
|
|
1766
|
+
' headers: {\\n' +
|
|
1767
|
+
' "Content-Type": "application/json",\\n' +
|
|
1768
|
+
' },\\n' +
|
|
1769
|
+
' body: JSON.stringify(' + bodyStr.split('\\n').map((l, i) => i === 0 ? l : ' ' + l).join('\\n') + '),\\n' +
|
|
1770
|
+
'});\\n\\n' +
|
|
1771
|
+
'const data = await response.json();\\n' +
|
|
1772
|
+
'console.log(data);';
|
|
1773
|
+
}
|
|
1774
|
+
return 'const response = await fetch("' + url + '"' +
|
|
1775
|
+
(method !== 'GET' ? ', {\\n method: "' + method + '",\\n}' : '') + ');\\n\\n' +
|
|
1776
|
+
'const data = await response.json();\\n' +
|
|
1777
|
+
'console.log(data);';
|
|
1778
|
+
|
|
1779
|
+
case 'python':
|
|
1780
|
+
if (hasBody) {
|
|
1781
|
+
return 'import requests\\n\\n' +
|
|
1782
|
+
'response = requests.' + method.toLowerCase() + '(\\n' +
|
|
1783
|
+
' "' + url + '",\\n' +
|
|
1784
|
+
' json=' + bodyStr.split('\\n').map((l, i) => i === 0 ? l : ' ' + l).join('\\n') + ',\\n' +
|
|
1785
|
+
')\\n\\n' +
|
|
1786
|
+
'print(response.json())';
|
|
1787
|
+
}
|
|
1788
|
+
return 'import requests\\n\\n' +
|
|
1789
|
+
'response = requests.' + method.toLowerCase() + '("' + url + '")\\n\\n' +
|
|
1790
|
+
'print(response.json())';
|
|
1791
|
+
|
|
1792
|
+
case 'go':
|
|
1793
|
+
if (hasBody) {
|
|
1794
|
+
return 'package main\\n\\n' +
|
|
1795
|
+
'import (\\n' +
|
|
1796
|
+
' "bytes"\\n' +
|
|
1797
|
+
' "encoding/json"\\n' +
|
|
1798
|
+
' "fmt"\\n' +
|
|
1799
|
+
' "net/http"\\n' +
|
|
1800
|
+
' "io"\\n' +
|
|
1801
|
+
')\\n\\n' +
|
|
1802
|
+
'func main() {\\n' +
|
|
1803
|
+
' body, _ := json.Marshal(map[string]interface{}{\\n' +
|
|
1804
|
+
generateGoMapBody(body) +
|
|
1805
|
+
' })\\n\\n' +
|
|
1806
|
+
' req, _ := http.NewRequest("' + method + '", "' + url + '", bytes.NewBuffer(body))\\n' +
|
|
1807
|
+
' req.Header.Set("Content-Type", "application/json")\\n\\n' +
|
|
1808
|
+
' client := &http.Client{}\\n' +
|
|
1809
|
+
' resp, _ := client.Do(req)\\n' +
|
|
1810
|
+
' defer resp.Body.Close()\\n\\n' +
|
|
1811
|
+
' data, _ := io.ReadAll(resp.Body)\\n' +
|
|
1812
|
+
' fmt.Println(string(data))\\n' +
|
|
1813
|
+
'}';
|
|
1814
|
+
}
|
|
1815
|
+
return 'package main\\n\\n' +
|
|
1816
|
+
'import (\\n' +
|
|
1817
|
+
' "fmt"\\n' +
|
|
1818
|
+
' "net/http"\\n' +
|
|
1819
|
+
' "io"\\n' +
|
|
1820
|
+
')\\n\\n' +
|
|
1821
|
+
'func main() {\\n' +
|
|
1822
|
+
' resp, _ := http.Get("' + url + '")\\n' +
|
|
1823
|
+
' defer resp.Body.Close()\\n\\n' +
|
|
1824
|
+
' body, _ := io.ReadAll(resp.Body)\\n' +
|
|
1825
|
+
' fmt.Println(string(body))\\n' +
|
|
1826
|
+
'}';
|
|
1827
|
+
|
|
1828
|
+
default:
|
|
1829
|
+
return '// Not implemented';
|
|
1830
|
+
}
|
|
1831
|
+
}
|
|
1832
|
+
|
|
1833
|
+
function generateGoMapBody(body) {
|
|
1834
|
+
if (!body || typeof body !== 'object') return '';
|
|
1835
|
+
const lines = [];
|
|
1836
|
+
for (const [key, value] of Object.entries(body)) {
|
|
1837
|
+
const goValue = typeof value === 'string' ? '"' + value + '"' :
|
|
1838
|
+
typeof value === 'number' ? String(value) :
|
|
1839
|
+
typeof value === 'boolean' ? String(value) :
|
|
1840
|
+
'nil';
|
|
1841
|
+
lines.push(' "' + key + '": ' + goValue + ',');
|
|
1842
|
+
}
|
|
1843
|
+
return lines.join('\\n') + '\\n';
|
|
1844
|
+
}
|
|
1845
|
+
|
|
1846
|
+
function buildExampleFromSchema(schema) {
|
|
1847
|
+
if (!schema) return null;
|
|
1848
|
+
|
|
1849
|
+
// Resolve $ref
|
|
1850
|
+
if (schema.$ref) {
|
|
1851
|
+
const resolved = resolveRef(schema.$ref);
|
|
1852
|
+
return buildExampleFromSchema(resolved);
|
|
1853
|
+
}
|
|
1854
|
+
|
|
1855
|
+
// Normalize non-standard format
|
|
1856
|
+
schema = normalizeSchema(schema);
|
|
1857
|
+
|
|
1858
|
+
if (schema.example !== undefined) return schema.example;
|
|
1859
|
+
if (schema.default !== undefined) return schema.default;
|
|
1860
|
+
|
|
1861
|
+
if (schema.type === 'object' && schema.properties) {
|
|
1862
|
+
const obj = {};
|
|
1863
|
+
for (const [key, prop] of Object.entries(schema.properties)) {
|
|
1864
|
+
obj[key] = buildExampleFromSchema(prop);
|
|
1865
|
+
}
|
|
1866
|
+
return obj;
|
|
1867
|
+
}
|
|
1868
|
+
|
|
1869
|
+
if (schema.type === 'array' && schema.items) {
|
|
1870
|
+
return [buildExampleFromSchema(schema.items)];
|
|
1871
|
+
}
|
|
1872
|
+
|
|
1873
|
+
// Primitive defaults
|
|
1874
|
+
switch (schema.type) {
|
|
1875
|
+
case 'string': return schema.format === 'email' ? 'user@example.com' : 'string';
|
|
1876
|
+
case 'number': return 0;
|
|
1877
|
+
case 'integer': return 0;
|
|
1878
|
+
case 'boolean': return true;
|
|
1879
|
+
default: return null;
|
|
1880
|
+
}
|
|
1881
|
+
}
|
|
1882
|
+
|
|
1883
|
+
// ========== SCHEMA RENDERING HELPERS ==========
|
|
1884
|
+
|
|
1885
|
+
function resolveRef(ref) {
|
|
1886
|
+
if (!ref || typeof ref !== 'string') return null;
|
|
1887
|
+
const parts = ref.replace('#/', '').split('/');
|
|
1888
|
+
let result = spec;
|
|
1889
|
+
for (const part of parts) {
|
|
1890
|
+
if (!result) return null;
|
|
1891
|
+
result = result[part];
|
|
1892
|
+
}
|
|
1893
|
+
return result;
|
|
1894
|
+
}
|
|
1895
|
+
|
|
1896
|
+
function getSchemaType(schema) {
|
|
1897
|
+
if (!schema) return 'any';
|
|
1898
|
+
if (schema.$ref) {
|
|
1899
|
+
const resolved = resolveRef(schema.$ref);
|
|
1900
|
+
return resolved ? getSchemaType(resolved) : 'ref';
|
|
1901
|
+
}
|
|
1902
|
+
if (schema.oneOf) return 'oneOf';
|
|
1903
|
+
if (schema.anyOf) return 'anyOf';
|
|
1904
|
+
if (schema.allOf) return 'allOf';
|
|
1905
|
+
if (Array.isArray(schema.type)) return schema.type.join(' | ');
|
|
1906
|
+
return schema.type || 'any';
|
|
1907
|
+
}
|
|
1908
|
+
|
|
1909
|
+
function getTypeClass(type) {
|
|
1910
|
+
const t = (type || '').toLowerCase();
|
|
1911
|
+
if (t === 'string') return 'type-string';
|
|
1912
|
+
if (t === 'number' || t === 'integer') return 'type-number';
|
|
1913
|
+
if (t === 'boolean') return 'type-boolean';
|
|
1914
|
+
if (t === 'object') return 'type-object';
|
|
1915
|
+
if (t === 'array') return 'type-array';
|
|
1916
|
+
if (t === 'null') return 'type-null';
|
|
1917
|
+
return 'type-ref';
|
|
1918
|
+
}
|
|
1919
|
+
|
|
1920
|
+
function getRefName(ref) {
|
|
1921
|
+
if (!ref) return '';
|
|
1922
|
+
const parts = ref.split('/');
|
|
1923
|
+
return parts[parts.length - 1];
|
|
1924
|
+
}
|
|
1925
|
+
|
|
1926
|
+
function renderSchemaType(schema, showFormat) {
|
|
1927
|
+
if (!schema) return '<span class="schema-type type-ref">any</span>';
|
|
1928
|
+
|
|
1929
|
+
if (schema.$ref) {
|
|
1930
|
+
const name = getRefName(schema.$ref);
|
|
1931
|
+
return '<span class="schema-type type-ref">' + esc(name) + '</span>';
|
|
1932
|
+
}
|
|
1933
|
+
|
|
1934
|
+
let type = getSchemaType(schema);
|
|
1935
|
+
let extra = '';
|
|
1936
|
+
|
|
1937
|
+
if (schema.format && showFormat !== false) {
|
|
1938
|
+
extra = '<' + schema.format + '>';
|
|
1939
|
+
}
|
|
1940
|
+
|
|
1941
|
+
if (type === 'array' && schema.items) {
|
|
1942
|
+
const itemType = schema.items.$ref
|
|
1943
|
+
? getRefName(schema.items.$ref)
|
|
1944
|
+
: getSchemaType(schema.items);
|
|
1945
|
+
return '<span class="schema-type type-array">array[' + esc(itemType) + ']</span>';
|
|
1946
|
+
}
|
|
1947
|
+
|
|
1948
|
+
if (type === 'oneOf' || type === 'anyOf' || type === 'allOf') {
|
|
1949
|
+
const items = schema[type];
|
|
1950
|
+
const types = items.map(s => s.$ref ? getRefName(s.$ref) : getSchemaType(s));
|
|
1951
|
+
return '<span class="schema-type type-ref">' + esc(type) + '(' + types.join(', ') + ')</span>';
|
|
1952
|
+
}
|
|
1953
|
+
|
|
1954
|
+
return '<span class="schema-type ' + getTypeClass(type) + '">' + esc(type + extra) + '</span>';
|
|
1955
|
+
}
|
|
1956
|
+
|
|
1957
|
+
function renderConstraints(schema) {
|
|
1958
|
+
const constraints = [];
|
|
1959
|
+
|
|
1960
|
+
// String constraints
|
|
1961
|
+
if (schema.minLength !== undefined) constraints.push('minLength: ' + schema.minLength);
|
|
1962
|
+
if (schema.maxLength !== undefined) constraints.push('maxLength: ' + schema.maxLength);
|
|
1963
|
+
if (schema.pattern) constraints.push('pattern: ' + schema.pattern);
|
|
1964
|
+
|
|
1965
|
+
// Number constraints
|
|
1966
|
+
if (schema.minimum !== undefined) constraints.push('min: ' + schema.minimum);
|
|
1967
|
+
if (schema.maximum !== undefined) constraints.push('max: ' + schema.maximum);
|
|
1968
|
+
if (schema.exclusiveMinimum !== undefined) constraints.push('exclusiveMin: ' + schema.exclusiveMinimum);
|
|
1969
|
+
if (schema.exclusiveMaximum !== undefined) constraints.push('exclusiveMax: ' + schema.exclusiveMaximum);
|
|
1970
|
+
if (schema.multipleOf !== undefined) constraints.push('multipleOf: ' + schema.multipleOf);
|
|
1971
|
+
|
|
1972
|
+
// Array constraints
|
|
1973
|
+
if (schema.minItems !== undefined) constraints.push('minItems: ' + schema.minItems);
|
|
1974
|
+
if (schema.maxItems !== undefined) constraints.push('maxItems: ' + schema.maxItems);
|
|
1975
|
+
if (schema.uniqueItems) constraints.push('uniqueItems');
|
|
1976
|
+
|
|
1977
|
+
// Object constraints
|
|
1978
|
+
if (schema.minProperties !== undefined) constraints.push('minProperties: ' + schema.minProperties);
|
|
1979
|
+
if (schema.maxProperties !== undefined) constraints.push('maxProperties: ' + schema.maxProperties);
|
|
1980
|
+
|
|
1981
|
+
if (constraints.length === 0) return '';
|
|
1982
|
+
|
|
1983
|
+
return '<div class="schema-constraints">' +
|
|
1984
|
+
constraints.map(c => '<span class="schema-constraint">' + esc(c) + '</span>').join('') +
|
|
1985
|
+
'</div>';
|
|
1986
|
+
}
|
|
1987
|
+
|
|
1988
|
+
function renderEnumValues(schema) {
|
|
1989
|
+
if (!schema.enum || schema.enum.length === 0) return '';
|
|
1990
|
+
|
|
1991
|
+
return '<div class="schema-enum">' +
|
|
1992
|
+
'<span style="font-size: 11px; color: var(--text-muted); margin-right: 4px;">Enum:</span>' +
|
|
1993
|
+
schema.enum.map(v => '<span class="schema-enum-value">' + esc(JSON.stringify(v)) + '</span>').join('') +
|
|
1994
|
+
'</div>';
|
|
1995
|
+
}
|
|
1996
|
+
|
|
1997
|
+
function renderDefault(schema) {
|
|
1998
|
+
if (schema.default === undefined) return '';
|
|
1999
|
+
return '<div class="schema-default">Default: <code>' + esc(JSON.stringify(schema.default)) + '</code></div>';
|
|
2000
|
+
}
|
|
2001
|
+
|
|
2002
|
+
let schemaIdCounter = 0;
|
|
2003
|
+
|
|
2004
|
+
// Normalize non-standard schema formats (e.g., from some Zod conversions)
|
|
2005
|
+
function normalizeSchema(schema) {
|
|
2006
|
+
if (!schema) return schema;
|
|
2007
|
+
|
|
2008
|
+
// Handle schemas with 'def' and 'shape' (non-standard Zod output)
|
|
2009
|
+
if (schema.def && schema.def.shape) {
|
|
2010
|
+
const normalized = { type: 'object', properties: {} };
|
|
2011
|
+
for (const [key, val] of Object.entries(schema.def.shape)) {
|
|
2012
|
+
normalized.properties[key] = normalizeSchema(val);
|
|
2013
|
+
}
|
|
2014
|
+
return normalized;
|
|
2015
|
+
}
|
|
2016
|
+
|
|
2017
|
+
// Handle 'innerType' for default values
|
|
2018
|
+
if (schema.def && schema.def.innerType) {
|
|
2019
|
+
const inner = normalizeSchema(schema.def.innerType);
|
|
2020
|
+
if (schema.def.defaultValue !== undefined) {
|
|
2021
|
+
inner.default = schema.def.defaultValue;
|
|
2022
|
+
}
|
|
2023
|
+
return inner;
|
|
2024
|
+
}
|
|
2025
|
+
|
|
2026
|
+
// Handle simple def types
|
|
2027
|
+
if (schema.def && schema.def.type === 'string') {
|
|
2028
|
+
const result = { type: 'string' };
|
|
2029
|
+
if (schema.format) result.format = schema.format;
|
|
2030
|
+
if (schema.minLength) result.minLength = schema.minLength;
|
|
2031
|
+
if (schema.maxLength) result.maxLength = schema.maxLength;
|
|
2032
|
+
return result;
|
|
2033
|
+
}
|
|
2034
|
+
|
|
2035
|
+
if (schema.def && schema.def.type === 'number') {
|
|
2036
|
+
return { type: 'number' };
|
|
2037
|
+
}
|
|
2038
|
+
|
|
2039
|
+
if (schema.def && schema.def.type === 'integer') {
|
|
2040
|
+
return { type: 'integer' };
|
|
2041
|
+
}
|
|
2042
|
+
|
|
2043
|
+
if (schema.def && schema.def.type === 'boolean') {
|
|
2044
|
+
return { type: 'boolean' };
|
|
2045
|
+
}
|
|
2046
|
+
|
|
2047
|
+
return schema;
|
|
2048
|
+
}
|
|
2049
|
+
|
|
2050
|
+
// ========== REDOC-STYLE RENDERING FUNCTIONS ==========
|
|
2051
|
+
|
|
2052
|
+
function renderParametersRedocStyle(params) {
|
|
2053
|
+
const container = document.createElement('div');
|
|
2054
|
+
|
|
2055
|
+
params.forEach(param => {
|
|
2056
|
+
const row = document.createElement('div');
|
|
2057
|
+
row.className = 'param-row';
|
|
2058
|
+
|
|
2059
|
+
// Tree line
|
|
2060
|
+
const tree = document.createElement('div');
|
|
2061
|
+
tree.className = 'param-tree';
|
|
2062
|
+
tree.innerHTML = '<div class="param-tree-line"></div>';
|
|
2063
|
+
row.appendChild(tree);
|
|
2064
|
+
|
|
2065
|
+
// Info
|
|
2066
|
+
const info = document.createElement('div');
|
|
2067
|
+
info.className = 'param-info';
|
|
2068
|
+
|
|
2069
|
+
// Header row: name, required badge, type
|
|
2070
|
+
const header = document.createElement('div');
|
|
2071
|
+
header.className = 'param-header';
|
|
2072
|
+
|
|
2073
|
+
const nameSpan = document.createElement('span');
|
|
2074
|
+
nameSpan.className = 'param-name-text';
|
|
2075
|
+
nameSpan.textContent = param.name;
|
|
2076
|
+
header.appendChild(nameSpan);
|
|
2077
|
+
|
|
2078
|
+
if (param.required) {
|
|
2079
|
+
const reqBadge = document.createElement('span');
|
|
2080
|
+
reqBadge.className = 'param-required-badge';
|
|
2081
|
+
reqBadge.textContent = 'required';
|
|
2082
|
+
header.appendChild(reqBadge);
|
|
2083
|
+
}
|
|
2084
|
+
|
|
2085
|
+
// Type info
|
|
2086
|
+
const schema = param.schema || {};
|
|
2087
|
+
const typeInfo = document.createElement('span');
|
|
2088
|
+
typeInfo.className = 'param-type-info';
|
|
2089
|
+
let typeText = schema.type || 'string';
|
|
2090
|
+
if (schema.format) {
|
|
2091
|
+
typeText += ' <span class="format"><' + esc(schema.format) + '></span>';
|
|
2092
|
+
}
|
|
2093
|
+
typeInfo.innerHTML = typeText;
|
|
2094
|
+
header.appendChild(typeInfo);
|
|
2095
|
+
|
|
2096
|
+
// Constraints
|
|
2097
|
+
if (schema.maximum !== undefined || schema.minimum !== undefined) {
|
|
2098
|
+
const constraint = document.createElement('span');
|
|
2099
|
+
constraint.className = 'param-constraint';
|
|
2100
|
+
if (schema.maximum !== undefined) {
|
|
2101
|
+
constraint.textContent = '<= ' + schema.maximum;
|
|
2102
|
+
} else if (schema.minimum !== undefined) {
|
|
2103
|
+
constraint.textContent = '>= ' + schema.minimum;
|
|
2104
|
+
}
|
|
2105
|
+
header.appendChild(constraint);
|
|
2106
|
+
}
|
|
2107
|
+
|
|
2108
|
+
info.appendChild(header);
|
|
2109
|
+
|
|
2110
|
+
// Default value
|
|
2111
|
+
if (schema.default !== undefined) {
|
|
2112
|
+
const def = document.createElement('div');
|
|
2113
|
+
def.className = 'param-default';
|
|
2114
|
+
def.innerHTML = 'Default: <code>' + esc(JSON.stringify(schema.default)) + '</code>';
|
|
2115
|
+
info.appendChild(def);
|
|
2116
|
+
}
|
|
2117
|
+
|
|
2118
|
+
// Example
|
|
2119
|
+
if (schema.example !== undefined || param.example !== undefined) {
|
|
2120
|
+
const ex = document.createElement('div');
|
|
2121
|
+
ex.className = 'param-example';
|
|
2122
|
+
const exValue = param.example !== undefined ? param.example : schema.example;
|
|
2123
|
+
ex.innerHTML = 'Example: <code>' + esc(param.name + '=' + exValue) + '</code>';
|
|
2124
|
+
info.appendChild(ex);
|
|
2125
|
+
}
|
|
2126
|
+
|
|
2127
|
+
// Description
|
|
2128
|
+
if (param.description || schema.description) {
|
|
2129
|
+
const desc = document.createElement('div');
|
|
2130
|
+
desc.className = 'param-description';
|
|
2131
|
+
desc.textContent = param.description || schema.description;
|
|
2132
|
+
info.appendChild(desc);
|
|
2133
|
+
}
|
|
2134
|
+
|
|
2135
|
+
row.appendChild(info);
|
|
2136
|
+
container.appendChild(row);
|
|
2137
|
+
});
|
|
2138
|
+
|
|
2139
|
+
return container;
|
|
2140
|
+
}
|
|
2141
|
+
|
|
2142
|
+
function renderRequestBodyRedocStyle(reqBody) {
|
|
2143
|
+
const container = document.createElement('div');
|
|
2144
|
+
|
|
2145
|
+
// Get schema
|
|
2146
|
+
const content = reqBody.content || {};
|
|
2147
|
+
const contentType = Object.keys(content)[0] || 'application/json';
|
|
2148
|
+
const mediaType = content[contentType] || {};
|
|
2149
|
+
const schema = mediaType.schema;
|
|
2150
|
+
|
|
2151
|
+
if (schema) {
|
|
2152
|
+
// Resolve and normalize
|
|
2153
|
+
let actualSchema = schema.$ref ? resolveRef(schema.$ref) : schema;
|
|
2154
|
+
actualSchema = normalizeSchema(actualSchema);
|
|
2155
|
+
|
|
2156
|
+
// Render properties as Redoc-style rows
|
|
2157
|
+
if (actualSchema && actualSchema.properties) {
|
|
2158
|
+
const required = actualSchema.required || [];
|
|
2159
|
+
Object.entries(actualSchema.properties).forEach(([propName, propSchema]) => {
|
|
2160
|
+
const row = renderPropertyRow(propName, propSchema, required.includes(propName), 0);
|
|
2161
|
+
container.appendChild(row);
|
|
2162
|
+
});
|
|
2163
|
+
} else if (actualSchema && actualSchema.type === 'array' && actualSchema.items) {
|
|
2164
|
+
const itemSchema = actualSchema.items.$ref ? resolveRef(actualSchema.items.$ref) : actualSchema.items;
|
|
2165
|
+
const arrayLabel = document.createElement('div');
|
|
2166
|
+
arrayLabel.style.marginBottom = '12px';
|
|
2167
|
+
arrayLabel.innerHTML = '<span class="param-type-info">Array [</span>';
|
|
2168
|
+
container.appendChild(arrayLabel);
|
|
2169
|
+
|
|
2170
|
+
if (itemSchema && itemSchema.properties) {
|
|
2171
|
+
const required = itemSchema.required || [];
|
|
2172
|
+
Object.entries(itemSchema.properties).forEach(([propName, propSchema]) => {
|
|
2173
|
+
const row = renderPropertyRow(propName, propSchema, required.includes(propName), 1);
|
|
2174
|
+
container.appendChild(row);
|
|
2175
|
+
});
|
|
2176
|
+
}
|
|
2177
|
+
|
|
2178
|
+
const arrayEnd = document.createElement('div');
|
|
2179
|
+
arrayEnd.innerHTML = '<span class="param-type-info">]</span>';
|
|
2180
|
+
container.appendChild(arrayEnd);
|
|
2181
|
+
}
|
|
2182
|
+
}
|
|
2183
|
+
|
|
2184
|
+
return container;
|
|
2185
|
+
}
|
|
2186
|
+
|
|
2187
|
+
function renderPropertyRow(name, schema, isRequired, depth) {
|
|
2188
|
+
const row = document.createElement('div');
|
|
2189
|
+
row.className = 'param-row';
|
|
2190
|
+
if (depth > 0) {
|
|
2191
|
+
row.style.paddingLeft = (depth * 20) + 'px';
|
|
2192
|
+
}
|
|
2193
|
+
|
|
2194
|
+
// Tree line
|
|
2195
|
+
const tree = document.createElement('div');
|
|
2196
|
+
tree.className = 'param-tree';
|
|
2197
|
+
tree.innerHTML = '<div class="param-tree-line"></div>';
|
|
2198
|
+
row.appendChild(tree);
|
|
2199
|
+
|
|
2200
|
+
// Info
|
|
2201
|
+
const info = document.createElement('div');
|
|
2202
|
+
info.className = 'param-info';
|
|
2203
|
+
|
|
2204
|
+
// Header row
|
|
2205
|
+
const header = document.createElement('div');
|
|
2206
|
+
header.className = 'param-header';
|
|
2207
|
+
|
|
2208
|
+
const nameSpan = document.createElement('span');
|
|
2209
|
+
nameSpan.className = 'param-name-text';
|
|
2210
|
+
nameSpan.textContent = name;
|
|
2211
|
+
header.appendChild(nameSpan);
|
|
2212
|
+
|
|
2213
|
+
if (isRequired) {
|
|
2214
|
+
const reqBadge = document.createElement('span');
|
|
2215
|
+
reqBadge.className = 'param-required-badge';
|
|
2216
|
+
reqBadge.textContent = 'required';
|
|
2217
|
+
header.appendChild(reqBadge);
|
|
2218
|
+
}
|
|
2219
|
+
|
|
2220
|
+
// Type info
|
|
2221
|
+
const resolved = schema.$ref ? resolveRef(schema.$ref) : schema;
|
|
2222
|
+
const normalized = normalizeSchema(resolved) || resolved || {};
|
|
2223
|
+
const typeInfo = document.createElement('span');
|
|
2224
|
+
typeInfo.className = 'param-type-info';
|
|
2225
|
+
let typeText = normalized.type || 'any';
|
|
2226
|
+
if (normalized.format) {
|
|
2227
|
+
typeText += ' <span class="format">(' + esc(normalized.format) + ')</span>';
|
|
2228
|
+
}
|
|
2229
|
+
if (schema.$ref) {
|
|
2230
|
+
typeText = '<span class="format">' + esc(getRefName(schema.$ref)) + '</span>';
|
|
2231
|
+
}
|
|
2232
|
+
typeInfo.innerHTML = typeText;
|
|
2233
|
+
header.appendChild(typeInfo);
|
|
2234
|
+
|
|
2235
|
+
// Pattern/constraint
|
|
2236
|
+
if (normalized.pattern) {
|
|
2237
|
+
const constraint = document.createElement('span');
|
|
2238
|
+
constraint.className = 'param-constraint';
|
|
2239
|
+
constraint.textContent = normalized.pattern;
|
|
2240
|
+
header.appendChild(constraint);
|
|
2241
|
+
}
|
|
2242
|
+
|
|
2243
|
+
info.appendChild(header);
|
|
2244
|
+
|
|
2245
|
+
// Default
|
|
2246
|
+
if (normalized.default !== undefined) {
|
|
2247
|
+
const def = document.createElement('div');
|
|
2248
|
+
def.className = 'param-default';
|
|
2249
|
+
def.innerHTML = 'Default: <code>' + esc(JSON.stringify(normalized.default)) + '</code>';
|
|
2250
|
+
info.appendChild(def);
|
|
2251
|
+
}
|
|
2252
|
+
|
|
2253
|
+
// Example
|
|
2254
|
+
if (normalized.example !== undefined) {
|
|
2255
|
+
const ex = document.createElement('div');
|
|
2256
|
+
ex.className = 'param-example';
|
|
2257
|
+
ex.innerHTML = 'Example: <code>' + esc(JSON.stringify(normalized.example)) + '</code>';
|
|
2258
|
+
info.appendChild(ex);
|
|
2259
|
+
}
|
|
2260
|
+
|
|
2261
|
+
// Description
|
|
2262
|
+
if (normalized.description) {
|
|
2263
|
+
const desc = document.createElement('div');
|
|
2264
|
+
desc.className = 'param-description';
|
|
2265
|
+
desc.textContent = normalized.description;
|
|
2266
|
+
info.appendChild(desc);
|
|
2267
|
+
}
|
|
2268
|
+
|
|
2269
|
+
row.appendChild(info);
|
|
2270
|
+
return row;
|
|
2271
|
+
}
|
|
2272
|
+
|
|
2273
|
+
function renderResponsesRedocStyle(responses) {
|
|
2274
|
+
const container = document.createElement('div');
|
|
2275
|
+
const statusCodes = Object.keys(responses).sort();
|
|
2276
|
+
|
|
2277
|
+
statusCodes.forEach((status, idx) => {
|
|
2278
|
+
const response = responses[status];
|
|
2279
|
+
const statusClass = status.startsWith('2') ? 'status-2xx' :
|
|
2280
|
+
status.startsWith('4') ? 'status-4xx' :
|
|
2281
|
+
status.startsWith('5') ? 'status-5xx' : '';
|
|
2282
|
+
|
|
2283
|
+
const item = document.createElement('div');
|
|
2284
|
+
item.className = 'response-item' + (idx === 0 ? ' expanded' : '');
|
|
2285
|
+
|
|
2286
|
+
// Header
|
|
2287
|
+
const header = document.createElement('div');
|
|
2288
|
+
header.className = 'response-header';
|
|
2289
|
+
header.innerHTML = '<span class="response-arrow">▶</span>' +
|
|
2290
|
+
'<span class="response-status ' + statusClass + '">' + esc(status) + '</span>' +
|
|
2291
|
+
'<span class="response-desc">' + esc(response.description || '') + '</span>';
|
|
2292
|
+
header.onclick = () => item.classList.toggle('expanded');
|
|
2293
|
+
item.appendChild(header);
|
|
2294
|
+
|
|
2295
|
+
// Body (headers + schema)
|
|
2296
|
+
const body = document.createElement('div');
|
|
2297
|
+
body.className = 'response-body';
|
|
2298
|
+
|
|
2299
|
+
// Render response headers if present
|
|
2300
|
+
if (response.headers && Object.keys(response.headers).length > 0) {
|
|
2301
|
+
const headersSection = document.createElement('div');
|
|
2302
|
+
headersSection.className = 'response-headers-section';
|
|
2303
|
+
|
|
2304
|
+
const headersLabel = document.createElement('div');
|
|
2305
|
+
headersLabel.className = 'response-headers-label';
|
|
2306
|
+
headersLabel.textContent = 'RESPONSE HEADERS';
|
|
2307
|
+
headersSection.appendChild(headersLabel);
|
|
2308
|
+
|
|
2309
|
+
Object.entries(response.headers).forEach(([headerName, headerDef]) => {
|
|
2310
|
+
const resolved = headerDef.$ref ? resolveRef(headerDef.$ref) : headerDef;
|
|
2311
|
+
const row = document.createElement('div');
|
|
2312
|
+
row.className = 'response-header-row';
|
|
2313
|
+
|
|
2314
|
+
const nameEl = document.createElement('div');
|
|
2315
|
+
nameEl.className = 'response-header-name';
|
|
2316
|
+
nameEl.textContent = headerName;
|
|
2317
|
+
if (resolved.required) {
|
|
2318
|
+
nameEl.innerHTML += '<span class="response-header-required">required</span>';
|
|
2319
|
+
}
|
|
2320
|
+
|
|
2321
|
+
const infoEl = document.createElement('div');
|
|
2322
|
+
infoEl.className = 'response-header-info';
|
|
2323
|
+
|
|
2324
|
+
const typeStr = resolved.schema ? (resolved.schema.type || 'string') : 'string';
|
|
2325
|
+
const typeEl = document.createElement('div');
|
|
2326
|
+
typeEl.className = 'response-header-type';
|
|
2327
|
+
typeEl.textContent = typeStr;
|
|
2328
|
+
infoEl.appendChild(typeEl);
|
|
2329
|
+
|
|
2330
|
+
if (resolved.description) {
|
|
2331
|
+
const descEl = document.createElement('div');
|
|
2332
|
+
descEl.className = 'response-header-desc';
|
|
2333
|
+
descEl.textContent = resolved.description;
|
|
2334
|
+
infoEl.appendChild(descEl);
|
|
2335
|
+
}
|
|
2336
|
+
|
|
2337
|
+
row.appendChild(nameEl);
|
|
2338
|
+
row.appendChild(infoEl);
|
|
2339
|
+
headersSection.appendChild(row);
|
|
2340
|
+
});
|
|
2341
|
+
|
|
2342
|
+
body.appendChild(headersSection);
|
|
2343
|
+
}
|
|
2344
|
+
|
|
2345
|
+
const respContent = response.content || {};
|
|
2346
|
+
const contentType = Object.keys(respContent)[0];
|
|
2347
|
+
if (contentType) {
|
|
2348
|
+
const label = document.createElement('div');
|
|
2349
|
+
label.className = 'response-schema-label';
|
|
2350
|
+
label.innerHTML = 'RESPONSE SCHEMA: <span class="content-type">' + esc(contentType) + '</span>';
|
|
2351
|
+
body.appendChild(label);
|
|
2352
|
+
|
|
2353
|
+
const mediaType = respContent[contentType] || {};
|
|
2354
|
+
const schema = mediaType.schema;
|
|
2355
|
+
if (schema) {
|
|
2356
|
+
let actualSchema = schema.$ref ? resolveRef(schema.$ref) : schema;
|
|
2357
|
+
actualSchema = normalizeSchema(actualSchema);
|
|
2358
|
+
|
|
2359
|
+
if (actualSchema && actualSchema.properties) {
|
|
2360
|
+
const required = actualSchema.required || [];
|
|
2361
|
+
Object.entries(actualSchema.properties).forEach(([propName, propSchema]) => {
|
|
2362
|
+
const row = renderPropertyRow(propName, propSchema, required.includes(propName), 0);
|
|
2363
|
+
body.appendChild(row);
|
|
2364
|
+
});
|
|
2365
|
+
} else if (actualSchema && actualSchema.type === 'array' && actualSchema.items) {
|
|
2366
|
+
const itemSchema = actualSchema.items.$ref ? resolveRef(actualSchema.items.$ref) : actualSchema.items;
|
|
2367
|
+
const arrayLabel = document.createElement('div');
|
|
2368
|
+
arrayLabel.innerHTML = '<span class="param-type-info">Array [</span>';
|
|
2369
|
+
arrayLabel.style.marginBottom = '8px';
|
|
2370
|
+
body.appendChild(arrayLabel);
|
|
2371
|
+
|
|
2372
|
+
if (itemSchema && itemSchema.properties) {
|
|
2373
|
+
const itemRequired = itemSchema.required || [];
|
|
2374
|
+
Object.entries(itemSchema.properties).forEach(([propName, propSchema]) => {
|
|
2375
|
+
const row = renderPropertyRow(propName, propSchema, itemRequired.includes(propName), 1);
|
|
2376
|
+
body.appendChild(row);
|
|
2377
|
+
});
|
|
2378
|
+
}
|
|
2379
|
+
|
|
2380
|
+
const arrayEnd = document.createElement('div');
|
|
2381
|
+
arrayEnd.innerHTML = '<span class="param-type-info">]</span>';
|
|
2382
|
+
body.appendChild(arrayEnd);
|
|
2383
|
+
}
|
|
2384
|
+
}
|
|
2385
|
+
}
|
|
2386
|
+
|
|
2387
|
+
item.appendChild(body);
|
|
2388
|
+
container.appendChild(item);
|
|
2389
|
+
});
|
|
2390
|
+
|
|
2391
|
+
return container;
|
|
2392
|
+
}
|
|
2393
|
+
|
|
2394
|
+
function renderSchemaProperties(schema, requiredProps, depth) {
|
|
2395
|
+
const container = document.createElement('div');
|
|
2396
|
+
container.className = 'schema-container';
|
|
2397
|
+
|
|
2398
|
+
// Normalize non-standard schemas first
|
|
2399
|
+
let actualSchema = normalizeSchema(schema);
|
|
2400
|
+
|
|
2401
|
+
// Handle $ref
|
|
2402
|
+
if (actualSchema.$ref) {
|
|
2403
|
+
const resolved = resolveRef(actualSchema.$ref);
|
|
2404
|
+
actualSchema = normalizeSchema(resolved) || actualSchema;
|
|
2405
|
+
}
|
|
2406
|
+
|
|
2407
|
+
// Handle allOf, oneOf, anyOf by merging/showing options
|
|
2408
|
+
if (actualSchema.allOf) {
|
|
2409
|
+
actualSchema.allOf.forEach((subSchema, idx) => {
|
|
2410
|
+
const resolved = subSchema.$ref ? resolveRef(subSchema.$ref) : subSchema;
|
|
2411
|
+
if (resolved && resolved.properties) {
|
|
2412
|
+
renderPropertiesInto(container, resolved, resolved.required || [], depth);
|
|
2413
|
+
}
|
|
2414
|
+
});
|
|
2415
|
+
return container;
|
|
2416
|
+
}
|
|
2417
|
+
|
|
2418
|
+
if (actualSchema.oneOf || actualSchema.anyOf) {
|
|
2419
|
+
const variants = actualSchema.oneOf || actualSchema.anyOf;
|
|
2420
|
+
const label = actualSchema.oneOf ? 'One of' : 'Any of';
|
|
2421
|
+
const row = document.createElement('div');
|
|
2422
|
+
row.className = 'schema-row';
|
|
2423
|
+
row.innerHTML = '<div class="schema-property">' +
|
|
2424
|
+
'<span class="schema-name" style="font-style: italic;">' + label + ':</span>' +
|
|
2425
|
+
'</div><div class="schema-details">' +
|
|
2426
|
+
variants.map((v, i) => {
|
|
2427
|
+
const name = v.$ref ? getRefName(v.$ref) : ('Option ' + (i + 1));
|
|
2428
|
+
return '<span class="schema-type type-ref" style="margin-right: 6px; cursor: pointer;">' + esc(name) + '</span>';
|
|
2429
|
+
}).join('') +
|
|
2430
|
+
'</div>';
|
|
2431
|
+
container.appendChild(row);
|
|
2432
|
+
return container;
|
|
2433
|
+
}
|
|
2434
|
+
|
|
2435
|
+
// Render object properties
|
|
2436
|
+
if (actualSchema.properties) {
|
|
2437
|
+
renderPropertiesInto(container, actualSchema, requiredProps || actualSchema.required || [], depth);
|
|
2438
|
+
} else if (actualSchema.type === 'array' && actualSchema.items) {
|
|
2439
|
+
// For arrays, show the items schema
|
|
2440
|
+
const itemSchema = actualSchema.items.$ref ? resolveRef(actualSchema.items.$ref) : actualSchema.items;
|
|
2441
|
+
if (itemSchema && itemSchema.properties) {
|
|
2442
|
+
renderPropertiesInto(container, itemSchema, itemSchema.required || [], depth);
|
|
2443
|
+
} else {
|
|
2444
|
+
const row = document.createElement('div');
|
|
2445
|
+
row.className = 'schema-row';
|
|
2446
|
+
row.innerHTML = '<div class="schema-property">' +
|
|
2447
|
+
'<span class="schema-name">[items]</span>' +
|
|
2448
|
+
'</div><div class="schema-details">' +
|
|
2449
|
+
renderSchemaType(actualSchema.items, true) +
|
|
2450
|
+
'</div>';
|
|
2451
|
+
container.appendChild(row);
|
|
2452
|
+
}
|
|
2453
|
+
} else if (Object.keys(actualSchema).length === 0 || actualSchema.type === 'object') {
|
|
2454
|
+
const row = document.createElement('div');
|
|
2455
|
+
row.className = 'schema-row';
|
|
2456
|
+
row.innerHTML = '<div class="schema-property">' +
|
|
2457
|
+
'<span class="schema-name" style="color: var(--text-muted); font-style: italic;">empty object</span>' +
|
|
2458
|
+
'</div>';
|
|
2459
|
+
container.appendChild(row);
|
|
2460
|
+
}
|
|
2461
|
+
|
|
2462
|
+
return container;
|
|
2463
|
+
}
|
|
2464
|
+
|
|
2465
|
+
function renderPropertiesInto(container, schema, requiredProps, depth) {
|
|
2466
|
+
const props = schema.properties || {};
|
|
2467
|
+
const required = requiredProps || [];
|
|
2468
|
+
const depthClass = depth > 0 ? ' nested' + (depth > 1 ? '-' + Math.min(depth, 4) : '') : '';
|
|
2469
|
+
|
|
2470
|
+
Object.entries(props).forEach(([propName, propSchema]) => {
|
|
2471
|
+
const isRequired = required.includes(propName);
|
|
2472
|
+
const resolved = propSchema.$ref ? resolveRef(propSchema.$ref) : propSchema;
|
|
2473
|
+
const hasNested = resolved && (resolved.properties || (resolved.type === 'array' && resolved.items?.properties));
|
|
2474
|
+
|
|
2475
|
+
const row = document.createElement('div');
|
|
2476
|
+
row.className = 'schema-row' + depthClass;
|
|
2477
|
+
|
|
2478
|
+
const id = 'schema-' + (schemaIdCounter++);
|
|
2479
|
+
|
|
2480
|
+
let toggleHtml = '';
|
|
2481
|
+
if (hasNested) {
|
|
2482
|
+
toggleHtml = '<span class="schema-toggle" data-target="' + id + '">▼ expand</span>';
|
|
2483
|
+
}
|
|
2484
|
+
|
|
2485
|
+
let detailsHtml = '<div class="schema-details">' +
|
|
2486
|
+
renderSchemaType(propSchema, true) + toggleHtml;
|
|
2487
|
+
|
|
2488
|
+
if (resolved?.description) {
|
|
2489
|
+
detailsHtml += '<div class="schema-desc">' + esc(resolved.description) + '</div>';
|
|
2490
|
+
}
|
|
2491
|
+
|
|
2492
|
+
detailsHtml += renderConstraints(resolved || {});
|
|
2493
|
+
detailsHtml += renderEnumValues(resolved || {});
|
|
2494
|
+
detailsHtml += renderDefault(resolved || {});
|
|
2495
|
+
detailsHtml += '</div>';
|
|
2496
|
+
|
|
2497
|
+
row.innerHTML = '<div class="schema-property">' +
|
|
2498
|
+
'<span class="schema-name">' + esc(propName) + '</span>' +
|
|
2499
|
+
(isRequired ? '<span class="schema-required">*</span>' : '') +
|
|
2500
|
+
'</div>' + detailsHtml;
|
|
2501
|
+
|
|
2502
|
+
container.appendChild(row);
|
|
2503
|
+
|
|
2504
|
+
// Add nested container for expandable schemas
|
|
2505
|
+
if (hasNested) {
|
|
2506
|
+
const nestedContainer = document.createElement('div');
|
|
2507
|
+
nestedContainer.id = id;
|
|
2508
|
+
nestedContainer.className = 'schema-nested-container collapsed';
|
|
2509
|
+
|
|
2510
|
+
if (resolved.properties) {
|
|
2511
|
+
const nested = renderSchemaProperties(resolved, resolved.required || [], depth + 1);
|
|
2512
|
+
nestedContainer.appendChild(nested);
|
|
2513
|
+
} else if (resolved.type === 'array' && resolved.items) {
|
|
2514
|
+
const itemSchema = resolved.items.$ref ? resolveRef(resolved.items.$ref) : resolved.items;
|
|
2515
|
+
if (itemSchema) {
|
|
2516
|
+
const nested = renderSchemaProperties(itemSchema, itemSchema.required || [], depth + 1);
|
|
2517
|
+
nestedContainer.appendChild(nested);
|
|
2518
|
+
}
|
|
2519
|
+
}
|
|
2520
|
+
|
|
2521
|
+
container.appendChild(nestedContainer);
|
|
2522
|
+
|
|
2523
|
+
// Add click handler for toggle
|
|
2524
|
+
const toggle = row.querySelector('.schema-toggle');
|
|
2525
|
+
if (toggle) {
|
|
2526
|
+
toggle.onclick = () => {
|
|
2527
|
+
nestedContainer.classList.toggle('collapsed');
|
|
2528
|
+
toggle.textContent = nestedContainer.classList.contains('collapsed') ? '▼ expand' : '▲ collapse';
|
|
2529
|
+
};
|
|
2530
|
+
}
|
|
2531
|
+
}
|
|
2532
|
+
});
|
|
2533
|
+
}
|
|
2534
|
+
|
|
2535
|
+
function renderParameters(params) {
|
|
2536
|
+
if (!params || params.length === 0) return null;
|
|
2537
|
+
|
|
2538
|
+
const container = document.createElement('div');
|
|
2539
|
+
const table = document.createElement('table');
|
|
2540
|
+
table.className = 'params-table';
|
|
2541
|
+
|
|
2542
|
+
const thead = document.createElement('thead');
|
|
2543
|
+
thead.innerHTML = '<tr><th>Name</th><th>Type</th><th>Description</th></tr>';
|
|
2544
|
+
table.appendChild(thead);
|
|
2545
|
+
|
|
2546
|
+
const tbody = document.createElement('tbody');
|
|
2547
|
+
params.forEach(param => {
|
|
2548
|
+
const schema = param.schema || {};
|
|
2549
|
+
const tr = document.createElement('tr');
|
|
2550
|
+
tr.innerHTML = '<td>' +
|
|
2551
|
+
'<span class="param-name">' + esc(param.name) + '</span>' +
|
|
2552
|
+
'<span class="param-in">' + esc(param.in) + '</span>' +
|
|
2553
|
+
(param.required ? '<span class="schema-required"> *</span>' : '') +
|
|
2554
|
+
'</td>' +
|
|
2555
|
+
'<td>' + renderSchemaType(schema, true) + '</td>' +
|
|
2556
|
+
'<td>' + esc(param.description || schema.description || '') +
|
|
2557
|
+
renderDefault(schema) + '</td>';
|
|
2558
|
+
tbody.appendChild(tr);
|
|
2559
|
+
});
|
|
2560
|
+
table.appendChild(tbody);
|
|
2561
|
+
container.appendChild(table);
|
|
2562
|
+
|
|
2563
|
+
return container;
|
|
2564
|
+
}
|
|
2565
|
+
|
|
2566
|
+
function renderRequestBody(reqBody) {
|
|
2567
|
+
if (!reqBody) return null;
|
|
2568
|
+
|
|
2569
|
+
const container = document.createElement('div');
|
|
2570
|
+
|
|
2571
|
+
if (reqBody.description) {
|
|
2572
|
+
const desc = document.createElement('p');
|
|
2573
|
+
desc.className = 'schema-desc';
|
|
2574
|
+
desc.textContent = reqBody.description;
|
|
2575
|
+
container.appendChild(desc);
|
|
2576
|
+
}
|
|
2577
|
+
|
|
2578
|
+
// Get content type (usually application/json)
|
|
2579
|
+
const content = reqBody.content || {};
|
|
2580
|
+
const contentType = Object.keys(content)[0] || 'application/json';
|
|
2581
|
+
const mediaType = content[contentType] || {};
|
|
2582
|
+
const schema = mediaType.schema;
|
|
2583
|
+
|
|
2584
|
+
if (schema) {
|
|
2585
|
+
const schemaEl = renderSchemaProperties(schema, schema.required || [], 0);
|
|
2586
|
+
container.appendChild(schemaEl);
|
|
2587
|
+
|
|
2588
|
+
// Show example if available
|
|
2589
|
+
if (mediaType.example || schema.example) {
|
|
2590
|
+
const example = mediaType.example || schema.example;
|
|
2591
|
+
const exampleDiv = document.createElement('div');
|
|
2592
|
+
exampleDiv.className = 'schema-example';
|
|
2593
|
+
exampleDiv.innerHTML = '<div class="schema-example-header">Example</div>' +
|
|
2594
|
+
'<div class="schema-example-body">' + esc(JSON.stringify(example, null, 2)) + '</div>';
|
|
2595
|
+
container.appendChild(exampleDiv);
|
|
2596
|
+
}
|
|
2597
|
+
}
|
|
2598
|
+
|
|
2599
|
+
return container;
|
|
2600
|
+
}
|
|
2601
|
+
|
|
2602
|
+
function renderResponses(responses) {
|
|
2603
|
+
if (!responses) return null;
|
|
2604
|
+
|
|
2605
|
+
const container = document.createElement('div');
|
|
2606
|
+
const statusCodes = Object.keys(responses).sort();
|
|
2607
|
+
|
|
2608
|
+
if (statusCodes.length === 0) return null;
|
|
2609
|
+
|
|
2610
|
+
// Create tabs
|
|
2611
|
+
const tabs = document.createElement('div');
|
|
2612
|
+
tabs.className = 'response-tabs';
|
|
2613
|
+
|
|
2614
|
+
const contents = document.createElement('div');
|
|
2615
|
+
|
|
2616
|
+
statusCodes.forEach((status, idx) => {
|
|
2617
|
+
const statusClass = status.startsWith('2') ? 'status-2xx' :
|
|
2618
|
+
status.startsWith('4') ? 'status-4xx' :
|
|
2619
|
+
status.startsWith('5') ? 'status-5xx' : '';
|
|
2620
|
+
|
|
2621
|
+
const tab = document.createElement('button');
|
|
2622
|
+
tab.className = 'response-tab ' + statusClass + (idx === 0 ? ' active' : '');
|
|
2623
|
+
tab.textContent = status;
|
|
2624
|
+
tab.dataset.status = status;
|
|
2625
|
+
tabs.appendChild(tab);
|
|
2626
|
+
|
|
2627
|
+
const content = document.createElement('div');
|
|
2628
|
+
content.className = 'response-content' + (idx === 0 ? ' active' : '');
|
|
2629
|
+
content.dataset.status = status;
|
|
2630
|
+
|
|
2631
|
+
const response = responses[status];
|
|
2632
|
+
if (response.description) {
|
|
2633
|
+
const desc = document.createElement('p');
|
|
2634
|
+
desc.className = 'schema-desc';
|
|
2635
|
+
desc.textContent = response.description;
|
|
2636
|
+
content.appendChild(desc);
|
|
2637
|
+
}
|
|
2638
|
+
|
|
2639
|
+
// Get schema from content
|
|
2640
|
+
const respContent = response.content || {};
|
|
2641
|
+
const contentType = Object.keys(respContent)[0] || 'application/json';
|
|
2642
|
+
const mediaType = respContent[contentType] || {};
|
|
2643
|
+
const schema = mediaType.schema;
|
|
2644
|
+
|
|
2645
|
+
if (schema) {
|
|
2646
|
+
const schemaEl = renderSchemaProperties(schema, schema.required || [], 0);
|
|
2647
|
+
content.appendChild(schemaEl);
|
|
2648
|
+
|
|
2649
|
+
// Show example if available
|
|
2650
|
+
if (mediaType.example || schema.example) {
|
|
2651
|
+
const example = mediaType.example || schema.example;
|
|
2652
|
+
const exampleDiv = document.createElement('div');
|
|
2653
|
+
exampleDiv.className = 'schema-example';
|
|
2654
|
+
exampleDiv.innerHTML = '<div class="schema-example-header">Example</div>' +
|
|
2655
|
+
'<div class="schema-example-body">' + esc(JSON.stringify(example, null, 2)) + '</div>';
|
|
2656
|
+
content.appendChild(exampleDiv);
|
|
2657
|
+
}
|
|
2658
|
+
}
|
|
2659
|
+
|
|
2660
|
+
contents.appendChild(content);
|
|
2661
|
+
});
|
|
2662
|
+
|
|
2663
|
+
container.appendChild(tabs);
|
|
2664
|
+
container.appendChild(contents);
|
|
2665
|
+
|
|
2666
|
+
// Tab click handler
|
|
2667
|
+
tabs.onclick = (e) => {
|
|
2668
|
+
if (e.target.classList.contains('response-tab')) {
|
|
2669
|
+
const status = e.target.dataset.status;
|
|
2670
|
+
tabs.querySelectorAll('.response-tab').forEach(t => t.classList.remove('active'));
|
|
2671
|
+
contents.querySelectorAll('.response-content').forEach(c => c.classList.remove('active'));
|
|
2672
|
+
e.target.classList.add('active');
|
|
2673
|
+
contents.querySelector('[data-status="' + status + '"]').classList.add('active');
|
|
2674
|
+
}
|
|
2675
|
+
};
|
|
2676
|
+
|
|
2677
|
+
return container;
|
|
2678
|
+
}
|
|
2679
|
+
|
|
2680
|
+
function resolveEffectiveContentTypes(operationTypes, protocolTypes) {
|
|
2681
|
+
const globalTypes = (xUsd && xUsd.contentTypes) ? xUsd.contentTypes : {};
|
|
2682
|
+
const defaultType =
|
|
2683
|
+
(operationTypes && operationTypes.default) ||
|
|
2684
|
+
(protocolTypes && protocolTypes.default) ||
|
|
2685
|
+
globalTypes.default ||
|
|
2686
|
+
'application/json';
|
|
2687
|
+
const supportedList =
|
|
2688
|
+
(operationTypes && operationTypes.supported) ||
|
|
2689
|
+
(protocolTypes && protocolTypes.supported) ||
|
|
2690
|
+
globalTypes.supported ||
|
|
2691
|
+
[];
|
|
2692
|
+
const supported = Array.isArray(supportedList) ? supportedList.slice() : [];
|
|
2693
|
+
if (defaultType && supported.indexOf(defaultType) === -1) {
|
|
2694
|
+
supported.unshift(defaultType);
|
|
2695
|
+
}
|
|
2696
|
+
return { default: defaultType, supported };
|
|
2697
|
+
}
|
|
2698
|
+
|
|
2699
|
+
function appendContentTypes(container, label, contentTypes) {
|
|
2700
|
+
if (!contentTypes) return;
|
|
2701
|
+
const section = document.createElement('div');
|
|
2702
|
+
section.className = 'endpoint-subsection';
|
|
2703
|
+
section.innerHTML = '<div class="subsection-label">' + esc(label) + '</div>';
|
|
2704
|
+
const grid = document.createElement('div');
|
|
2705
|
+
grid.className = 'info-grid';
|
|
2706
|
+
const supportedText = (contentTypes.supported && contentTypes.supported.length > 0)
|
|
2707
|
+
? contentTypes.supported.join(', ')
|
|
2708
|
+
: contentTypes.default;
|
|
2709
|
+
grid.innerHTML =
|
|
2710
|
+
'<div class="info-card"><div class="info-card-title">Default</div><div class="info-card-value">' +
|
|
2711
|
+
esc(contentTypes.default || 'application/json') + '</div></div>' +
|
|
2712
|
+
'<div class="info-card"><div class="info-card-title">Supported</div><div class="info-card-value">' +
|
|
2713
|
+
esc(supportedText || 'application/json') + '</div></div>';
|
|
2714
|
+
section.appendChild(grid);
|
|
2715
|
+
container.appendChild(section);
|
|
2716
|
+
}
|
|
2717
|
+
|
|
2718
|
+
function renderEndpointDetails(ep) {
|
|
2719
|
+
const container = document.createElement('div');
|
|
2720
|
+
const data = ep.data;
|
|
2721
|
+
|
|
2722
|
+
// HTTP-specific (Redoc-style layout)
|
|
2723
|
+
if (activeProtocol === 'http') {
|
|
2724
|
+
// AUTHORIZATIONS section
|
|
2725
|
+
if (data.security && data.security.length > 0) {
|
|
2726
|
+
const authSection = document.createElement('div');
|
|
2727
|
+
authSection.className = 'endpoint-subsection';
|
|
2728
|
+
authSection.innerHTML = '<div class="subsection-label">AUTHORIZATIONS:</div>';
|
|
2729
|
+
const authValue = document.createElement('span');
|
|
2730
|
+
authValue.className = 'auth-value';
|
|
2731
|
+
const authNames = data.security.flatMap(s => Object.keys(s));
|
|
2732
|
+
authValue.textContent = authNames.join(', ') || 'None';
|
|
2733
|
+
authSection.appendChild(authValue);
|
|
2734
|
+
container.appendChild(authSection);
|
|
2735
|
+
}
|
|
2736
|
+
|
|
2737
|
+
// PATH PARAMETERS
|
|
2738
|
+
const pathParams = (data.parameters || []).filter(p => p.in === 'path');
|
|
2739
|
+
if (pathParams.length > 0) {
|
|
2740
|
+
const section = document.createElement('div');
|
|
2741
|
+
section.className = 'endpoint-subsection';
|
|
2742
|
+
section.innerHTML = '<div class="subsection-label">PATH PARAMETERS</div>';
|
|
2743
|
+
section.appendChild(renderParametersRedocStyle(pathParams));
|
|
2744
|
+
container.appendChild(section);
|
|
2745
|
+
}
|
|
2746
|
+
|
|
2747
|
+
// QUERY PARAMETERS
|
|
2748
|
+
const queryParams = (data.parameters || []).filter(p => p.in === 'query');
|
|
2749
|
+
if (queryParams.length > 0) {
|
|
2750
|
+
const section = document.createElement('div');
|
|
2751
|
+
section.className = 'endpoint-subsection';
|
|
2752
|
+
section.innerHTML = '<div class="subsection-label">QUERY PARAMETERS</div>';
|
|
2753
|
+
section.appendChild(renderParametersRedocStyle(queryParams));
|
|
2754
|
+
container.appendChild(section);
|
|
2755
|
+
}
|
|
2756
|
+
|
|
2757
|
+
// HEADER PARAMETERS
|
|
2758
|
+
const headerParams = (data.parameters || []).filter(p => p.in === 'header');
|
|
2759
|
+
if (headerParams.length > 0) {
|
|
2760
|
+
const section = document.createElement('div');
|
|
2761
|
+
section.className = 'endpoint-subsection';
|
|
2762
|
+
section.innerHTML = '<div class="subsection-label">HEADER PARAMETERS</div>';
|
|
2763
|
+
section.appendChild(renderParametersRedocStyle(headerParams));
|
|
2764
|
+
container.appendChild(section);
|
|
2765
|
+
}
|
|
2766
|
+
|
|
2767
|
+
// REQUEST BODY SCHEMA
|
|
2768
|
+
if (data.requestBody) {
|
|
2769
|
+
const section = document.createElement('div');
|
|
2770
|
+
section.className = 'endpoint-subsection';
|
|
2771
|
+
const contentType = Object.keys(data.requestBody.content || {})[0] || 'application/json';
|
|
2772
|
+
section.innerHTML = '<div class="subsection-label">REQUEST BODY SCHEMA: <span class="content-type">' + esc(contentType) + '</span></div>';
|
|
2773
|
+
const bodyEl = renderRequestBodyRedocStyle(data.requestBody);
|
|
2774
|
+
if (bodyEl) section.appendChild(bodyEl);
|
|
2775
|
+
container.appendChild(section);
|
|
2776
|
+
}
|
|
2777
|
+
|
|
2778
|
+
// RESPONSES
|
|
2779
|
+
if (data.responses) {
|
|
2780
|
+
const section = document.createElement('div');
|
|
2781
|
+
section.className = 'endpoint-subsection';
|
|
2782
|
+
section.innerHTML = '<div class="subsection-label">Responses</div>';
|
|
2783
|
+
section.appendChild(renderResponsesRedocStyle(data.responses));
|
|
2784
|
+
container.appendChild(section);
|
|
2785
|
+
}
|
|
2786
|
+
}
|
|
2787
|
+
|
|
2788
|
+
// WebSocket-specific
|
|
2789
|
+
if (activeProtocol === 'websocket') {
|
|
2790
|
+
if (data.type) {
|
|
2791
|
+
const badge = document.createElement('span');
|
|
2792
|
+
badge.className = 'badge channel-type-' + data.type;
|
|
2793
|
+
badge.textContent = data.type;
|
|
2794
|
+
badge.style.marginBottom = '16px';
|
|
2795
|
+
badge.style.display = 'inline-block';
|
|
2796
|
+
container.appendChild(badge);
|
|
2797
|
+
}
|
|
2798
|
+
if (data.subscribe) {
|
|
2799
|
+
appendContentTypes(
|
|
2800
|
+
container,
|
|
2801
|
+
'Subscribe Content Types',
|
|
2802
|
+
resolveEffectiveContentTypes(data.subscribe?.contentTypes, wsSpec?.contentTypes)
|
|
2803
|
+
);
|
|
2804
|
+
}
|
|
2805
|
+
if (data.publish) {
|
|
2806
|
+
appendContentTypes(
|
|
2807
|
+
container,
|
|
2808
|
+
'Publish Content Types',
|
|
2809
|
+
resolveEffectiveContentTypes(data.publish?.contentTypes, wsSpec?.contentTypes)
|
|
2810
|
+
);
|
|
2811
|
+
}
|
|
2812
|
+
if (data.parameters) {
|
|
2813
|
+
const paramSchema = { type: 'object', properties: {}, required: [] };
|
|
2814
|
+
Object.entries(data.parameters).forEach(([name, param]) => {
|
|
2815
|
+
const schema = param.schema || { type: 'string' };
|
|
2816
|
+
if (param.description) schema.description = param.description;
|
|
2817
|
+
paramSchema.properties[name] = schema;
|
|
2818
|
+
if (param.required) paramSchema.required.push(name);
|
|
2819
|
+
});
|
|
2820
|
+
const h = document.createElement('h4');
|
|
2821
|
+
h.textContent = 'Parameters';
|
|
2822
|
+
container.appendChild(h);
|
|
2823
|
+
const schemaEl = renderSchemaProperties(paramSchema, paramSchema.required, 0);
|
|
2824
|
+
container.appendChild(schemaEl);
|
|
2825
|
+
}
|
|
2826
|
+
const subscribePayload = resolveMessagePayload(data.subscribe?.message);
|
|
2827
|
+
if (subscribePayload) {
|
|
2828
|
+
const h = document.createElement('h4');
|
|
2829
|
+
h.textContent = 'Subscribe (receive)';
|
|
2830
|
+
container.appendChild(h);
|
|
2831
|
+
const schemaEl = renderSchemaProperties(subscribePayload, [], 0);
|
|
2832
|
+
container.appendChild(schemaEl);
|
|
2833
|
+
}
|
|
2834
|
+
const publishPayload = resolveMessagePayload(data.publish?.message);
|
|
2835
|
+
if (publishPayload) {
|
|
2836
|
+
const h = document.createElement('h4');
|
|
2837
|
+
h.textContent = 'Publish (send)';
|
|
2838
|
+
container.appendChild(h);
|
|
2839
|
+
const schemaEl = renderSchemaProperties(publishPayload, [], 0);
|
|
2840
|
+
container.appendChild(schemaEl);
|
|
2841
|
+
}
|
|
2842
|
+
}
|
|
2843
|
+
|
|
2844
|
+
// Streams-specific
|
|
2845
|
+
if (activeProtocol === 'streams') {
|
|
2846
|
+
if (data.direction) {
|
|
2847
|
+
const badge = document.createElement('span');
|
|
2848
|
+
badge.className = 'badge badge-stream';
|
|
2849
|
+
badge.textContent = data.direction;
|
|
2850
|
+
badge.style.marginBottom = '16px';
|
|
2851
|
+
badge.style.display = 'inline-block';
|
|
2852
|
+
container.appendChild(badge);
|
|
2853
|
+
}
|
|
2854
|
+
appendContentTypes(
|
|
2855
|
+
container,
|
|
2856
|
+
'Content Types',
|
|
2857
|
+
resolveEffectiveContentTypes(data.contentTypes, streamsSpec?.contentTypes)
|
|
2858
|
+
);
|
|
2859
|
+
const streamPayload = resolveMessagePayload(data.message);
|
|
2860
|
+
if (streamPayload) {
|
|
2861
|
+
const h = document.createElement('h4');
|
|
2862
|
+
h.textContent = 'Message Schema';
|
|
2863
|
+
container.appendChild(h);
|
|
2864
|
+
const schemaEl = renderSchemaProperties(streamPayload, [], 0);
|
|
2865
|
+
container.appendChild(schemaEl);
|
|
2866
|
+
}
|
|
2867
|
+
}
|
|
2868
|
+
|
|
2869
|
+
// JSON-RPC-specific
|
|
2870
|
+
if (activeProtocol === 'jsonrpc') {
|
|
2871
|
+
if (data['x-usd-notification'] || data['x-usd-streaming']) {
|
|
2872
|
+
const flags = [];
|
|
2873
|
+
if (data['x-usd-notification']) flags.push('notification');
|
|
2874
|
+
if (data['x-usd-streaming']) flags.push('streaming');
|
|
2875
|
+
const info = document.createElement('div');
|
|
2876
|
+
info.style.marginBottom = '16px';
|
|
2877
|
+
info.innerHTML = flags.map(f => '<span class="badge badge-rpc" style="margin-right: 6px;">' + esc(f) + '</span>').join('');
|
|
2878
|
+
container.appendChild(info);
|
|
2879
|
+
}
|
|
2880
|
+
appendContentTypes(
|
|
2881
|
+
container,
|
|
2882
|
+
'Content Types',
|
|
2883
|
+
resolveEffectiveContentTypes(data.contentTypes, jsonrpcSpec?.contentTypes)
|
|
2884
|
+
);
|
|
2885
|
+
if (data.params) {
|
|
2886
|
+
const h = document.createElement('h4');
|
|
2887
|
+
h.textContent = 'Parameters';
|
|
2888
|
+
container.appendChild(h);
|
|
2889
|
+
const schemaEl = renderSchemaProperties(data.params, data.params.required || [], 0);
|
|
2890
|
+
container.appendChild(schemaEl);
|
|
2891
|
+
}
|
|
2892
|
+
if (data.result) {
|
|
2893
|
+
const h = document.createElement('h4');
|
|
2894
|
+
h.textContent = 'Result';
|
|
2895
|
+
container.appendChild(h);
|
|
2896
|
+
const schemaEl = renderSchemaProperties(data.result, [], 0);
|
|
2897
|
+
container.appendChild(schemaEl);
|
|
2898
|
+
}
|
|
2899
|
+
if (Array.isArray(data.errors) && data.errors.length > 0) {
|
|
2900
|
+
const section = document.createElement('div');
|
|
2901
|
+
section.className = 'endpoint-subsection';
|
|
2902
|
+
section.innerHTML = '<div class="subsection-label">Errors</div>';
|
|
2903
|
+
data.errors.forEach((err) => {
|
|
2904
|
+
const card = document.createElement('div');
|
|
2905
|
+
card.className = 'info-card';
|
|
2906
|
+
card.innerHTML =
|
|
2907
|
+
'<div class="info-card-title">' + esc(err.code) + '</div>' +
|
|
2908
|
+
'<div class="info-card-value">' + esc(err.message) + '</div>' +
|
|
2909
|
+
(err.description ? '<div class="info-card-subtitle">' + esc(err.description) + '</div>' : '');
|
|
2910
|
+
section.appendChild(card);
|
|
2911
|
+
if (err.data) {
|
|
2912
|
+
const schemaEl = renderSchemaProperties(err.data, [], 0);
|
|
2913
|
+
section.appendChild(schemaEl);
|
|
2914
|
+
}
|
|
2915
|
+
});
|
|
2916
|
+
container.appendChild(section);
|
|
2917
|
+
}
|
|
2918
|
+
}
|
|
2919
|
+
|
|
2920
|
+
// gRPC-specific
|
|
2921
|
+
if (activeProtocol === 'grpc') {
|
|
2922
|
+
const method = data.method;
|
|
2923
|
+
if (method) {
|
|
2924
|
+
const methodType = getGrpcMethodType(method);
|
|
2925
|
+
if (methodType && methodType !== 'unary') {
|
|
2926
|
+
const badge = document.createElement('span');
|
|
2927
|
+
badge.className = 'badge badge-stream';
|
|
2928
|
+
badge.textContent = methodType.replace('_', ' ');
|
|
2929
|
+
badge.style.marginBottom = '16px';
|
|
2930
|
+
badge.style.display = 'inline-block';
|
|
2931
|
+
container.appendChild(badge);
|
|
2932
|
+
}
|
|
2933
|
+
appendContentTypes(
|
|
2934
|
+
container,
|
|
2935
|
+
'Content Types',
|
|
2936
|
+
resolveEffectiveContentTypes(method.contentTypes, grpcSpec?.contentTypes)
|
|
2937
|
+
);
|
|
2938
|
+
if (method.input) {
|
|
2939
|
+
const h = document.createElement('h4');
|
|
2940
|
+
h.textContent = 'Request';
|
|
2941
|
+
container.appendChild(h);
|
|
2942
|
+
const schemaEl = renderSchemaProperties(method.input, [], 0);
|
|
2943
|
+
container.appendChild(schemaEl);
|
|
2944
|
+
}
|
|
2945
|
+
if (method.output) {
|
|
2946
|
+
const h = document.createElement('h4');
|
|
2947
|
+
h.textContent = 'Response';
|
|
2948
|
+
container.appendChild(h);
|
|
2949
|
+
const schemaEl = renderSchemaProperties(method.output, [], 0);
|
|
2950
|
+
container.appendChild(schemaEl);
|
|
2951
|
+
}
|
|
2952
|
+
}
|
|
2953
|
+
}
|
|
2954
|
+
|
|
2955
|
+
// TCP-specific
|
|
2956
|
+
if (activeProtocol === 'tcp') {
|
|
2957
|
+
const grid = document.createElement('div');
|
|
2958
|
+
grid.className = 'info-grid';
|
|
2959
|
+
grid.innerHTML =
|
|
2960
|
+
'<div class="info-card"><div class="info-card-title">Host</div><div class="info-card-value">' +
|
|
2961
|
+
esc(data.host || 'localhost') + '</div></div>' +
|
|
2962
|
+
'<div class="info-card"><div class="info-card-title">Port</div><div class="info-card-value">' +
|
|
2963
|
+
(data.port || 'N/A') + '</div></div>' +
|
|
2964
|
+
(data.tls?.enabled ? '<div class="info-card"><div class="info-card-title">TLS</div><div class="info-card-value">Enabled</div></div>' : '');
|
|
2965
|
+
container.appendChild(grid);
|
|
2966
|
+
appendContentTypes(
|
|
2967
|
+
container,
|
|
2968
|
+
'Content Types',
|
|
2969
|
+
resolveEffectiveContentTypes(data.contentTypes, tcpSpec?.contentTypes)
|
|
2970
|
+
);
|
|
2971
|
+
if (data.framing) {
|
|
2972
|
+
const h = document.createElement('h4');
|
|
2973
|
+
h.textContent = 'Framing';
|
|
2974
|
+
container.appendChild(h);
|
|
2975
|
+
const schemaEl = renderSchemaProperties(data.framing, [], 0);
|
|
2976
|
+
container.appendChild(schemaEl);
|
|
2977
|
+
}
|
|
2978
|
+
if (data.messages?.inbound || data.messages?.outbound) {
|
|
2979
|
+
if (data.messages?.inbound) {
|
|
2980
|
+
const h = document.createElement('h4');
|
|
2981
|
+
h.textContent = 'Inbound Message';
|
|
2982
|
+
container.appendChild(h);
|
|
2983
|
+
const schemaEl = renderSchemaProperties(resolveMessagePayload(data.messages.inbound), [], 0);
|
|
2984
|
+
container.appendChild(schemaEl);
|
|
2985
|
+
}
|
|
2986
|
+
if (data.messages?.outbound) {
|
|
2987
|
+
const h = document.createElement('h4');
|
|
2988
|
+
h.textContent = 'Outbound Message';
|
|
2989
|
+
container.appendChild(h);
|
|
2990
|
+
const schemaEl = renderSchemaProperties(resolveMessagePayload(data.messages.outbound), [], 0);
|
|
2991
|
+
container.appendChild(schemaEl);
|
|
2992
|
+
}
|
|
2993
|
+
}
|
|
2994
|
+
}
|
|
2995
|
+
|
|
2996
|
+
// UDP-specific
|
|
2997
|
+
if (activeProtocol === 'udp') {
|
|
2998
|
+
const grid = document.createElement('div');
|
|
2999
|
+
grid.className = 'info-grid';
|
|
3000
|
+
grid.innerHTML =
|
|
3001
|
+
'<div class="info-card"><div class="info-card-title">Host</div><div class="info-card-value">' +
|
|
3002
|
+
esc(data.host || '0.0.0.0') + '</div></div>' +
|
|
3003
|
+
'<div class="info-card"><div class="info-card-title">Port</div><div class="info-card-value">' +
|
|
3004
|
+
(data.port || 'N/A') + '</div></div>' +
|
|
3005
|
+
'<div class="info-card"><div class="info-card-title">Max Packet</div><div class="info-card-value">' +
|
|
3006
|
+
(data.maxPacketSize || 65507) + ' bytes</div></div>';
|
|
3007
|
+
container.appendChild(grid);
|
|
3008
|
+
appendContentTypes(
|
|
3009
|
+
container,
|
|
3010
|
+
'Content Types',
|
|
3011
|
+
resolveEffectiveContentTypes(data.contentTypes, udpSpec?.contentTypes)
|
|
3012
|
+
);
|
|
3013
|
+
if (data.messages?.inbound) {
|
|
3014
|
+
const h = document.createElement('h4');
|
|
3015
|
+
h.textContent = 'Inbound Message';
|
|
3016
|
+
container.appendChild(h);
|
|
3017
|
+
const schemaEl = renderSchemaProperties(resolveMessagePayload(data.messages.inbound), [], 0);
|
|
3018
|
+
container.appendChild(schemaEl);
|
|
3019
|
+
}
|
|
3020
|
+
if (data.messages?.outbound) {
|
|
3021
|
+
const h = document.createElement('h4');
|
|
3022
|
+
h.textContent = 'Outbound Message';
|
|
3023
|
+
container.appendChild(h);
|
|
3024
|
+
const schemaEl = renderSchemaProperties(resolveMessagePayload(data.messages.outbound), [], 0);
|
|
3025
|
+
container.appendChild(schemaEl);
|
|
3026
|
+
}
|
|
3027
|
+
if (!data.messages?.inbound && !data.messages?.outbound && data.message) {
|
|
3028
|
+
const h = document.createElement('h4');
|
|
3029
|
+
h.textContent = 'Message Schema';
|
|
3030
|
+
container.appendChild(h);
|
|
3031
|
+
const schemaEl = renderSchemaProperties(resolveMessagePayload(data.message), [], 0);
|
|
3032
|
+
container.appendChild(schemaEl);
|
|
3033
|
+
}
|
|
3034
|
+
}
|
|
3035
|
+
|
|
3036
|
+
return container;
|
|
3037
|
+
}
|
|
3038
|
+
|
|
3039
|
+
function getGrpcMethodType(method) {
|
|
3040
|
+
const client = method['x-usd-client-streaming'];
|
|
3041
|
+
const server = method['x-usd-server-streaming'];
|
|
3042
|
+
if (client && server) return 'bidirectional';
|
|
3043
|
+
if (client) return 'client_streaming';
|
|
3044
|
+
if (server) return 'server_streaming';
|
|
3045
|
+
return 'unary';
|
|
3046
|
+
}
|
|
3047
|
+
|
|
3048
|
+
function resolveMessagePayload(message) {
|
|
3049
|
+
if (!message) return null;
|
|
3050
|
+
if (message.$ref) {
|
|
3051
|
+
const resolved = resolveRef(message.$ref);
|
|
3052
|
+
if (resolved && resolved.payload) return resolved.payload;
|
|
3053
|
+
return resolved || message;
|
|
3054
|
+
}
|
|
3055
|
+
if (message.payload) return message.payload;
|
|
3056
|
+
return message;
|
|
3057
|
+
}
|
|
3058
|
+
|
|
3059
|
+
// Initial render
|
|
3060
|
+
renderProtocolTabs();
|
|
3061
|
+
renderSidebar();
|
|
3062
|
+
renderContent();
|
|
3063
|
+
`;
|
|
3064
|
+
}
|
|
3065
|
+
//# sourceMappingURL=html-builder.js.map
|