UNPKG

swagger-autogen-validator

Version:

This module performs the automatic construction of the Swagger documentation. The module can identify the endpoints and automatically capture methods such as to get, post, put, and so on. The module can also identify the paths, routes, middlewares, respon

314 lines (307 loc) 9.69 kB
const tableStatusCodes_enUS = { 100: 'Continue', 101: 'Switching Protocols', 102: 'Processing', 103: 'Early Hints', 200: 'OK', 201: 'Created', 202: 'Accepted', 203: 'Non-Authoritative Information', 204: 'No Content', 205: 'Reset Content', 206: 'Partial Content', 207: 'Multi-Status', 208: 'Already Reported', 226: 'IM Used', 300: 'Multiple Choices', 301: 'Moved Permanently', 302: 'Found', 303: 'See Other', 304: 'Not Modified', 305: 'Use Proxy', 306: 'Switch Proxy', 307: 'Temporary Redirect', 308: 'Permanent Redirect', 400: 'Bad Request', 401: 'Unauthorized', 402: 'Payment Required', 403: 'Forbidden', 404: 'Not Found', 405: 'Method Not Allowed', 406: 'Not Acceptable', 407: 'Proxy Authentication Required', 408: 'Request Timeout', 409: 'Conflict', 410: 'Gone', 411: 'Length Required', 412: 'Precondition Failed', 413: 'Payload Too Large', 414: 'URI Too Long', 415: 'Unsupported Media Type', 416: 'Range Not Satisfiable', 417: 'Expectation Failed', 418: "I'm a teapot", 421: 'Misdirected Request', 422: 'Unprocessable Entity', 423: 'Locked', 424: 'Failed Dependency', 425: 'Too Early', 426: 'Upgrade Required', 428: 'Precondition Required', 429: 'Too Many Requests', 431: 'Request Header Fields Too Large', 444: 'Connection Closed Without Response', 451: 'Unavailable For Legal Reasons', 499: 'Client Closed Request', 500: 'Internal Server Error', 501: 'Not Implemented', 502: 'Bad Gateway', 503: 'Service Unavailable', 504: 'Gateway Timeout', 505: 'HTTP Version Not Supported', 506: 'Variant Also Negotiates', 507: 'Insufficient Storage', 508: 'Loop Detected', 510: 'Not Extended', 511: 'Network Authentication Required', 599: 'Network Connect Timeout Error' }; const tableStatusCodes_ptBR = { 100: 'Continuar', 101: 'Mudando Protocolos', 102: 'Processando', 200: 'OK', 201: 'Criado', 202: 'Aceito', 203: 'Informação Não Autorizada', 204: 'Nenhum Conteúdo', 205: 'Resetar Conteúdo', 206: 'Conteúdo Parcial', 300: 'Múltipla Escolha', 301: 'Movido Permanentemente', 302: 'Encontrado', 303: 'Veja Outro', 304: 'Não Modificado', 305: 'Use Proxy', 306: 'Proxy Trocado', 400: 'Solicitação Inválida', 401: 'Não autorizado', 402: 'Pagamento Necessário', 403: 'Acesso Negado', 404: 'Não Encontrado', 405: 'Método Não Permitido', 406: 'Não Aceito', 407: 'Autenticação de Proxy Necessária', 408: 'Tempo de Solicitação Esgotado', 409: 'Conflito', 410: 'Perdido', 411: 'Duração Necessária', 412: 'Falha de Pré-condição', 413: 'Solicitação da Entidade Muito Extensa', 414: 'Solicitação de URL Muito Longa', 415: 'Tipo de Mídia Não Suportado', 416: 'Solicitação de Faixa Não Satisfatória', 417: 'Falha Na Expectativa', 500: 'Erro Interno do Servidor', 501: 'Não Implementado', 502: 'Porta de Entrada Ruim', 503: 'Serviço Indisponível', 504: 'Tempo Limite da Porta de Entrada', 505: 'Versão HTTP Não Suportada', 506: 'Variante Também Negocia', 507: 'Armazenamento Insuficiente', 508: 'Loop Detectado', 510: 'Não Estendido', 511: 'Requer Autenticação de Rede', 599: 'Erro de Tempo Limite de Conexão à Rede' }; const tableStatusCodes_zhCN = { 100: '继续', 101: '切换协议', 102: '处理中', 200: '成功', 201: '已创建', 202: '已接受', 203: '非授权信息', 204: '无内容', 205: '重置内容', 206: '部分内容', 300: '多种选择', 301: '永久移动', 302: '临时移动', 303: '查看其他位置', 304: '未修改', 305: '使用代理', 306: '切换代理', 307: '临时重定向', 400: '错误请求', 401: '未授权', 402: '需要付款', 403: '禁止', 404: '未找到', 405: '方法禁用', 406: '不接受', 407: '需要代理授权', 408: '请求超时', 409: '冲突', 410: '已删除', 411: '需要有效长度', 412: '未满足前提条件', 413: '请求实体过大', 414: '请求的 URI 过长', 415: '不支持的媒体类型', 416: '请求范围不符合要求', 417: '未满足期望值', 500: '服务器内部错误', 501: '尚未实施', 502: '错误网关', 503: '服务不可用', 504: '网关超时', 505: 'HTTP 版本不受支持', 506: '变体也可协商', 507: '存储空间不足', 508: '检测到循环', 510: '不扩展', 511: '需要网络验证', 599: '网络连接超时错误' }; const tableStatusCodes_ko = { 100: '계속', 101: '프로토콜 전환', 102: '처리', 200: '성공', 201: '작성됨', 202: '허용됨', 203: '신뢰할 수 없는 정보', 204: '콘텐츠 없음', 205: '콘텐츠 재설정', 206: '일부 콘텐츠', 300: '여러 선택항목', 301: '영구 이동', 302: '임시 이동', 303: '기타 위치 보기', 304: '수정되지 않음', 305: '프록시 사용', 306: '프록시 전환', 307: '임시 리다이렉션', 400: '잘못된 요청', 401: '권한 없음', 402: '결제 필요', 403: '금지됨', 404: '찾을 수 없음', 405: '허용되지 않는 방법', 406: '허용되지 않음', 407: '프록시 인증 필요', 408: '요청 시간초과', 409: '충돌', 410: '사라짐', 411: '길이 필요', 412: '사전조건 실패', 413: '요청 속성이 너무 큼', 414: '요청 URI가 너무 긺', 415: '지원되지 않는 미디어 유형', 416: '처리할 수 없는 요청범위', 417: '예상 실패', 500: '내부 서버 오류', 501: '구현되지 않음', 502: '불량 게이트웨이', 503: '서비스를 사용할 수 없음', 504: '게이트웨이 시간초과', 505: 'HTTP 버전이 지원되지 않음', 506: '변형도 협상', 507: '용량 부족', 508: '루프 감지됨', 510: '확장되지 않음', 511: '네트워크 인증 필요', 599: '네트워크 연결 시간초과 오류' }; const tableStatusCodes_frFR = { 100: 'Continuer', 101: 'Changement de Protocole', 102: 'Traitement en Cours', 103: 'Early Hints', //todo 200: 'OK', 201: 'Créé', 202: 'Accepté', 203: 'Non-Authoritative Information', 204: 'Aucun Contenu', 205: 'Réinitialiser le Contenu', 206: 'Contenu Partiel', 207: 'Multi-statuts', 208: 'Déjà Signalé', 226: 'IM Used', //todo 300: 'Choix Multiples', 301: 'Déplacé Définitivement', 302: 'Trouvé', 303: 'Voir Autre', 304: 'Non Modifié', 305: 'Utiliser Proxy', 306: 'Changer Proxy', 307: 'Redirection Temporaire', 308: 'Redirection Permanente', 400: 'Mauvaise Requête', 401: 'Non Autorisé', 402: 'Paiement Requis', 403: 'Interdit', 404: 'Non Trouvé', 405: 'Méthode Non Autorisée', 406: 'Non Acceptable', 407: 'Authentification Proxy Requise', 408: 'Requête Expiré', 409: 'Conflit', 410: 'Parti', 411: 'Longueur Exigée', 412: 'Précondition Échouée', 413: 'Entité de la Requête Trop Grande', 414: 'URI Trop Long', 415: 'Type de Média Non Supporté', 416: 'Plage Demandée Invalide', 417: 'Comportement Erroné', 418: 'Je Suis Une Théière', 421: 'Requête Mal Dirigé', 422: 'Entité Non Traitable', 423: 'Verrouillé', 424: 'Dépendance échouée', 425: 'Trop Tôt', 426: 'Mise à Niveau Requise', 428: 'Condition Préalable Requise', 429: 'Trop de Requêtes', 431: 'Entêtes requête HTTP émises Trop Grande', 444: 'Connexion fermée Sans réponse', 451: 'Indisponible pour des Raisons Légales', 499: 'Le Client a Fermé la Connexion', 500: 'Erreur Interne du Serveur', 501: 'Non Implémenté', 502: 'Passerelle Invalide', 503: 'Service Non Disponible', 504: 'Délai Passerelle Expirée', 505: 'Version HTTP Non Prise en Charge', 506: 'Variant Also Negotiates', 507: 'Espace Insuffisant', 508: 'Boucle Détectée', 510: 'Non Étendu', 511: 'Authentification Réseau Requise', 599: 'Erreur Délai de Connexion au Réseau' }; function getHttpStatusDescription(statusCode, lang) { lang = lang.toLowerCase(); if (lang == 'pt-br') { // Portuguese - Brazil return tableStatusCodes_ptBR[statusCode] ? tableStatusCodes_ptBR[statusCode] : ''; } else if (lang == 'zh-cn') { // Chinese (Simplified) return tableStatusCodes_zhCN[statusCode] ? tableStatusCodes_zhCN[statusCode] : ''; } else if (lang == 'ko') { // Korean return tableStatusCodes_ko[statusCode] ? tableStatusCodes_ko[statusCode] : ''; } else if (lang == 'fr') { // French return tableStatusCodes_frFR[statusCode] ? tableStatusCodes_frFR[statusCode] : ''; } else { // English by default return tableStatusCodes_enUS[statusCode] ? tableStatusCodes_enUS[statusCode] : ''; } } module.exports = { getHttpStatusDescription };