@@ -1813,3 +1813,149 @@ testCase(
18131813 } ,
18141814 } ,
18151815) ;
1816+
1817+ const ROUTE_WITH_ENUM_DEPRECATED = `
1818+ import * as t from 'io-ts';
1819+ import * as h from '@api-ts/io-ts-http';
1820+
1821+ /**
1822+ * Enum with @deprecated tags - should generate x-enumsDeprecated
1823+ */
1824+ export const StatusWithDeprecated = t.keyof(
1825+ {
1826+ /**
1827+ * @description Transaction is waiting for approval from authorized users
1828+ */
1829+ pendingApproval: 1,
1830+ /**
1831+ * @description Transaction was canceled by the user
1832+ * @deprecated
1833+ */
1834+ canceled: 1,
1835+ /**
1836+ * @description Transaction was rejected by approvers
1837+ * @deprecated
1838+ */
1839+ rejected: 1,
1840+ },
1841+ 'StatusWithDeprecated',
1842+ );
1843+
1844+ /**
1845+ * Enum with only @deprecated tags - should generate x-enumsDeprecated
1846+ */
1847+ export const StatusOnlyDeprecated = t.keyof(
1848+ {
1849+ /** @deprecated */
1850+ old: 1,
1851+ current: 1,
1852+ /** @deprecated */
1853+ legacy: 1,
1854+ },
1855+ 'StatusOnlyDeprecated',
1856+ );
1857+
1858+ /**
1859+ * Route to test enum deprecated scenarios
1860+ *
1861+ * @operationId api.v1.enumDeprecatedScenarios
1862+ * @tag Test Routes
1863+ */
1864+ export const route = h.httpRoute({
1865+ path: '/enum-deprecated',
1866+ method: 'GET',
1867+ request: h.httpRequest({
1868+ query: {
1869+ withDeprecated: StatusWithDeprecated,
1870+ onlyDeprecated: StatusOnlyDeprecated,
1871+ },
1872+ }),
1873+ response: {
1874+ 200: {
1875+ result: t.string
1876+ }
1877+ },
1878+ });
1879+ ` ;
1880+
1881+ testCase (
1882+ 'enum deprecated scenarios - @deprecated tags with and without @description' ,
1883+ ROUTE_WITH_ENUM_DEPRECATED ,
1884+ {
1885+ openapi : '3.0.3' ,
1886+ info : {
1887+ title : 'Test' ,
1888+ version : '1.0.0' ,
1889+ } ,
1890+ paths : {
1891+ '/enum-deprecated' : {
1892+ get : {
1893+ summary : 'Route to test enum deprecated scenarios' ,
1894+ operationId : 'api.v1.enumDeprecatedScenarios' ,
1895+ tags : [ 'Test Routes' ] ,
1896+ parameters : [
1897+ {
1898+ name : 'withDeprecated' ,
1899+ in : 'query' ,
1900+ required : true ,
1901+ schema : {
1902+ $ref : '#/components/schemas/StatusWithDeprecated' ,
1903+ } ,
1904+ } ,
1905+ {
1906+ name : 'onlyDeprecated' ,
1907+ in : 'query' ,
1908+ required : true ,
1909+ schema : {
1910+ $ref : '#/components/schemas/StatusOnlyDeprecated' ,
1911+ } ,
1912+ } ,
1913+ ] ,
1914+ responses : {
1915+ 200 : {
1916+ description : 'OK' ,
1917+ content : {
1918+ 'application/json' : {
1919+ schema : {
1920+ type : 'object' ,
1921+ properties : {
1922+ result : {
1923+ type : 'string' ,
1924+ } ,
1925+ } ,
1926+ required : [ 'result' ] ,
1927+ } ,
1928+ } ,
1929+ } ,
1930+ } ,
1931+ } ,
1932+ } ,
1933+ } ,
1934+ } ,
1935+ components : {
1936+ schemas : {
1937+ StatusWithDeprecated : {
1938+ title : 'StatusWithDeprecated' ,
1939+ description : 'Enum with @deprecated tags - should generate x-enumsDeprecated' ,
1940+ type : 'string' ,
1941+ enum : [ 'pendingApproval' , 'canceled' , 'rejected' ] ,
1942+ 'x-enumDescriptions' : {
1943+ pendingApproval :
1944+ 'Transaction is waiting for approval from authorized users' ,
1945+ canceled : 'Transaction was canceled by the user' ,
1946+ rejected : 'Transaction was rejected by approvers' ,
1947+ } ,
1948+ 'x-enumsDeprecated' : [ 'canceled' , 'rejected' ] ,
1949+ } ,
1950+ StatusOnlyDeprecated : {
1951+ title : 'StatusOnlyDeprecated' ,
1952+ description :
1953+ 'Enum with only @deprecated tags - should generate x-enumsDeprecated' ,
1954+ type : 'string' ,
1955+ enum : [ 'old' , 'current' , 'legacy' ] ,
1956+ 'x-enumsDeprecated' : [ 'old' , 'legacy' ] ,
1957+ } ,
1958+ } ,
1959+ } ,
1960+ } ,
1961+ ) ;
0 commit comments