diff --git a/Directory.Build.props b/Directory.Build.props index ad5be64..d7ebca5 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,8 +1,8 @@ - 3.1.0 - 3.0.0 + 3.2.0 + 3.1.0 12.0 enable enable diff --git a/Directory.Packages.props b/Directory.Packages.props index 6c07034..b1ee154 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -3,8 +3,8 @@ true - - + + diff --git a/ReleaseNotes.md b/ReleaseNotes.md index fbd047a..7faa085 100644 --- a/ReleaseNotes.md +++ b/ReleaseNotes.md @@ -2,6 +2,10 @@ These are the NuGet package releases. See also [npm Release Notes](ReleaseNotesNpm.md). +## 3.2.0 + +* Support `float` field type. + ## 3.1.0 * Drop support for end-of-life frameworks. diff --git a/conformance/ConformanceApi.fsd b/conformance/ConformanceApi.fsd index 85a03e2..54eca85 100644 --- a/conformance/ConformanceApi.fsd +++ b/conformance/ConformanceApi.fsd @@ -145,6 +145,7 @@ service ConformanceApi { string: string; boolean: boolean; + float: float; double: double; int32: int32; int64: int64; @@ -155,11 +156,12 @@ service ConformanceApi { } - [http(method: GET, path: "/checkPath/{string}/{boolean}/{double}/{int32}/{int64}/{decimal}/{enum}/{datetime}")] + [http(method: GET, path: "/checkPath/{string}/{boolean}/{float}/{double}/{int32}/{int64}/{decimal}/{enum}/{datetime}")] method checkPath { string: string; boolean: boolean; + float: float; double: double; int32: int32; int64: int64; @@ -175,6 +177,7 @@ service ConformanceApi { [http(from: header)] string: string; [http(from: header)] boolean: boolean; + [http(from: header)] float: float; [http(from: header)] double: double; [http(from: header)] int32: int32; [http(from: header)] int64: int64; @@ -185,6 +188,7 @@ service ConformanceApi { [http(from: header)] string: string; [http(from: header)] boolean: boolean; + [http(from: header)] float: float; [http(from: header)] double: double; [http(from: header)] int32: int32; [http(from: header)] int64: int64; @@ -266,6 +270,7 @@ service ConformanceApi { string: string; boolean: boolean; + float: float; double: double; int32: int32; int64: int64; @@ -286,6 +291,7 @@ service ConformanceApi { string: string[]; boolean: boolean[]; + float: float[]; double: double[]; int32: int32[]; int64: int64[]; @@ -306,6 +312,7 @@ service ConformanceApi { string: map; boolean: map; + float: map; double: map; int32: map; int64: map; @@ -326,6 +333,7 @@ service ConformanceApi { string: result; boolean: result; + float: result; double: result; int32: result; int64: result; @@ -346,6 +354,7 @@ service ConformanceApi { string: nullable; boolean: nullable; + float: nullable; double: nullable; int32: nullable; int64: nullable; diff --git a/conformance/ConformanceTests.json b/conformance/ConformanceTests.json index 405be38..87ad004 100644 --- a/conformance/ConformanceTests.json +++ b/conformance/ConformanceTests.json @@ -6,6 +6,7 @@ "request": { "string": "string", "boolean": true, + "float": 0.1875, "double": 0.375, "int32": 42, "int64": 12345678910, @@ -21,6 +22,7 @@ "request": { "string": "string", "boolean": true, + "float": 0.1875, "double": 0.375, "int32": 42, "int64": 12345678910, @@ -203,6 +205,7 @@ "array": { "string": ["string", "\n"], "boolean": [true, false], + "float": [0.1875, -0.75], "double": [0.375, -1.5], "int32": [42, 24], "int64": [12345678910, -987654321], @@ -226,6 +229,7 @@ "array": { "string": ["string", "\n"], "boolean": [true, false], + "float": [0.1875, -0.75], "double": [0.375, -1.5], "int32": [42, 24], "int64": [12345678910, -987654321], @@ -252,6 +256,7 @@ "field": { "string": "string", "boolean": true, + "float": 0.1875, "double": 0.375, "int32": 42, "int64": 12345678910, @@ -268,6 +273,7 @@ "field": { "string": "string", "boolean": true, + "float": 0.1875, "double": 0.375, "int32": 42, "int64": 12345678910, @@ -287,6 +293,7 @@ "request": { "string": "string", "boolean": true, + "float": 0.1875, "double": 0.375, "int32": 42, "int64": 12345678910, @@ -297,6 +304,7 @@ "response": { "string": "string", "boolean": true, + "float": 0.1875, "double": 0.375, "int32": 42, "int64": 12345678910, @@ -319,6 +327,7 @@ "map": { "string": { "": "string", " ": "\n" }, "boolean": { "": true, " ": false }, + "float": { "": 0.1875, " ": -0.75 }, "double": { "": 0.375, " ": -1.5 }, "int32": { "": 42, " ": 24 }, "int64": { "": 12345678910, " ": -987654321 }, @@ -341,6 +350,7 @@ "map": { "string": { "": "string", " ": "\n" }, "boolean": { "": true, " ": false }, + "float": { "": 0.1875, " ": -0.75 }, "double": { "": 0.375, " ": -1.5 }, "int32": { "": 42, " ": 24 }, "int64": { "": 12345678910, " ": -987654321 }, @@ -367,6 +377,7 @@ "nullable": { "string": "string", "boolean": true, + "float": 0.1875, "double": 0.375, "int32": 42, "int64": 12345678910, @@ -388,6 +399,7 @@ "nullable": { "string": "string", "boolean": true, + "float": 0.1875, "double": 0.375, "int32": 42, "int64": 12345678910, @@ -429,6 +441,7 @@ "nullable": { "string": null, "boolean": null, + "float": null, "double": null, "int32": null, "int64": null, @@ -450,6 +463,7 @@ "nullable": { "string": null, "boolean": null, + "float": null, "double": null, "int32": null, "int64": null, @@ -475,6 +489,7 @@ "result": { "string": { "error": { "code": "code", "message": "message", "innerError": { "code": "code" }, "details": { "": null, " ": [null] } } }, "boolean": { "error": { "code": "code", "message": "message", "innerError": { "code": "code" }, "details": { "": null, " ": [null] } } }, + "float": { "error": { "code": "code", "message": "message", "innerError": { "code": "code" }, "details": { "": null, " ": [null] } } }, "double": { "error": { "code": "code", "message": "message", "innerError": { "code": "code" }, "details": { "": null, " ": [null] } } }, "int32": { "error": { "code": "code", "message": "message", "innerError": { "code": "code" }, "details": { "": null, " ": [null] } } }, "int64": { "error": { "code": "code", "message": "message", "innerError": { "code": "code" }, "details": { "": null, " ": [null] } } }, @@ -496,6 +511,7 @@ "result": { "string": { "error": { "code": "code", "message": "message", "innerError": { "code": "code" }, "details": { "": null, " ": [null] } } }, "boolean": { "error": { "code": "code", "message": "message", "innerError": { "code": "code" }, "details": { "": null, " ": [null] } } }, + "float": { "error": { "code": "code", "message": "message", "innerError": { "code": "code" }, "details": { "": null, " ": [null] } } }, "double": { "error": { "code": "code", "message": "message", "innerError": { "code": "code" }, "details": { "": null, " ": [null] } } }, "int32": { "error": { "code": "code", "message": "message", "innerError": { "code": "code" }, "details": { "": null, " ": [null] } } }, "int64": { "error": { "code": "code", "message": "message", "innerError": { "code": "code" }, "details": { "": null, " ": [null] } } }, @@ -521,6 +537,7 @@ "result": { "string": { "value": "string" }, "boolean": { "value": true }, + "float": { "value": 0.1875 }, "double": { "value": 0.375 }, "int32": { "value": 42 }, "int64": { "value": 12345678910 }, @@ -543,6 +560,7 @@ "result": { "string": { "value": "string" }, "boolean": { "value": true }, + "float": { "value": 0.1875 }, "double": { "value": 0.375 }, "int32": { "value": 42 }, "int64": { "value": 12345678910 }, @@ -785,11 +803,12 @@ "method": "checkPath", "httpRequest": { "method": "GET", - "path": "/CHECKPATH/pathCase/true/1.5/3/4/0.625/yes/2001-02-03T04:05:06Z" + "path": "/CHECKPATH/pathCase/true/0.75/1.5/3/4/0.625/yes/2001-02-03T04:05:06Z" }, "request": { "string": "pathCase", "boolean": true, + "float": 0.75, "double": 1.5, "int32": 3, "int64": 4, @@ -804,11 +823,12 @@ "method": "checkPath", "httpRequest": { "method": "GET", - "path": "/checkPath/booleanCase/TRUE/1.5/3/4/0.625/yes/2001-02-03T04:05:06Z" + "path": "/checkPath/booleanCase/TRUE/0.75/1.5/3/4/0.625/yes/2001-02-03T04:05:06Z" }, "request": { "string": "booleanCase", "boolean": true, + "float": 0.75, "double": 1.5, "int32": 3, "int64": 4, @@ -823,11 +843,12 @@ "method": "checkQuery", "httpRequest": { "method": "GET", - "path": "/CHECKQUERY?string=pathCase&boolean=true&double=1.5&int32=3&int64=4&decimal=0.625&enum=yes&datetime=2001-02-03T04:05:06Z" + "path": "/CHECKQUERY?string=pathCase&boolean=true&float=0.75&double=1.5&int32=3&int64=4&decimal=0.625&enum=yes&datetime=2001-02-03T04:05:06Z" }, "request": { "string": "pathCase", "boolean": true, + "float": 0.75, "double": 1.5, "int32": 3, "int64": 4, @@ -842,11 +863,12 @@ "method": "checkQuery", "httpRequest": { "method": "GET", - "path": "/checkQuery?STRING=queryCase&boolean=true&double=1.5&int32=3&int64=4&decimal=0.625&enum=yes&datetime=2001-02-03T04:05:06Z" + "path": "/checkQuery?STRING=queryCase&boolean=true&float=0.75&double=1.5&int32=3&int64=4&decimal=0.625&enum=yes&datetime=2001-02-03T04:05:06Z" }, "request": { "string": "queryCase", "boolean": true, + "float": 0.75, "double": 1.5, "int32": 3, "int64": 4, diff --git a/conformance/src/conformanceApi.ts b/conformance/src/conformanceApi.ts index 8c1e794..2b3c152 100644 --- a/conformance/src/conformanceApi.ts +++ b/conformance/src/conformanceApi.ts @@ -254,6 +254,7 @@ class ConformanceApiHttpClient implements IConformanceApi { const query: string[] = []; request.string == null || query.push('string=' + encodeURIComponent(request.string)); request.boolean == null || query.push('boolean=' + request.boolean.toString()); + request.float == null || query.push('float=' + encodeURIComponent(request.float.toString())); request.double == null || query.push('double=' + encodeURIComponent(request.double.toString())); request.int32 == null || query.push('int32=' + request.int32.toString()); request.int64 == null || query.push('int64=' + request.int64.toString()); @@ -289,6 +290,10 @@ class ConformanceApiHttpClient implements IConformanceApi { if (!uriPartBoolean) { return Promise.resolve(createRequiredRequestFieldError('boolean')); } + const uriPartFloat = request.float != null && encodeURIComponent(request.float.toString()); + if (!uriPartFloat) { + return Promise.resolve(createRequiredRequestFieldError('float')); + } const uriPartDouble = request.double != null && encodeURIComponent(request.double.toString()); if (!uriPartDouble) { return Promise.resolve(createRequiredRequestFieldError('double')); @@ -313,7 +318,7 @@ class ConformanceApiHttpClient implements IConformanceApi { if (!uriPartDatetime) { return Promise.resolve(createRequiredRequestFieldError('datetime')); } - const uri = `checkPath/${uriPartString}/${uriPartBoolean}/${uriPartDouble}/${uriPartInt32}/${uriPartInt64}/${uriPartDecimal}/${uriPartEnum}/${uriPartDatetime}`; + const uri = `checkPath/${uriPartString}/${uriPartBoolean}/${uriPartFloat}/${uriPartDouble}/${uriPartInt32}/${uriPartInt64}/${uriPartDecimal}/${uriPartEnum}/${uriPartDatetime}`; const fetchRequest: IFetchRequest = { method: 'GET', }; @@ -343,6 +348,9 @@ class ConformanceApiHttpClient implements IConformanceApi { if (request.boolean != null) { fetchRequest.headers!['boolean'] = request.boolean.toString(); } + if (request.float != null) { + fetchRequest.headers!['float'] = request.float.toString(); + } if (request.double != null) { fetchRequest.headers!['double'] = request.double.toString(); } @@ -380,6 +388,10 @@ class ConformanceApiHttpClient implements IConformanceApi { if (headerValue != null) { value.boolean = parseBoolean(headerValue); } + headerValue = result.response.headers.get('float'); + if (headerValue != null) { + value.float = parseFloat(headerValue); + } headerValue = result.response.headers.get('double'); if (headerValue != null) { value.double = parseFloat(headerValue); diff --git a/conformance/src/conformanceApiTypes.ts b/conformance/src/conformanceApiTypes.ts index 9fbcc8f..8c52913 100644 --- a/conformance/src/conformanceApiTypes.ts +++ b/conformance/src/conformanceApiTypes.ts @@ -156,6 +156,8 @@ export interface ICheckQueryRequest { boolean?: boolean; + float?: number; + double?: number; int32?: number; @@ -179,6 +181,8 @@ export interface ICheckPathRequest { boolean?: boolean; + float?: number; + double?: number; int32?: number; @@ -202,6 +206,8 @@ export interface IMirrorHeadersRequest { boolean?: boolean; + float?: number; + double?: number; int32?: number; @@ -221,6 +227,8 @@ export interface IMirrorHeadersResponse { boolean?: boolean; + float?: number; + double?: number; int32?: number; @@ -336,6 +344,8 @@ export interface IAny { boolean?: boolean; + float?: number; + double?: number; int32?: number; @@ -370,6 +380,8 @@ export interface IAnyArray { boolean?: boolean[]; + float?: number[]; + double?: number[]; int32?: number[]; @@ -404,6 +416,8 @@ export interface IAnyMap { boolean?: { [name: string]: boolean }; + float?: { [name: string]: number }; + double?: { [name: string]: number }; int32?: { [name: string]: number }; @@ -438,6 +452,8 @@ export interface IAnyResult { boolean?: IServiceResult; + float?: IServiceResult; + double?: IServiceResult; int32?: IServiceResult; @@ -472,6 +488,8 @@ export interface IAnyNullable { boolean?: (boolean | null); + float?: (number | null); + double?: (number | null); int32?: (number | null); diff --git a/conformance/src/fastify/conformanceApiPlugin.ts b/conformance/src/fastify/conformanceApiPlugin.ts index 79d2ee9..e831ad0 100644 --- a/conformance/src/fastify/conformanceApiPlugin.ts +++ b/conformance/src/fastify/conformanceApiPlugin.ts @@ -356,6 +356,7 @@ export const conformanceApiPlugin: FastifyPluginAsync; if (typeof query['string'] === 'string') request.string = query['string']; if (typeof query['boolean'] === 'string') request.boolean = parseBoolean(query['boolean']); + if (typeof query['float'] === 'string') request.float = parseFloat(query['float']); if (typeof query['double'] === 'string') request.double = parseFloat(query['double']); if (typeof query['int32'] === 'string') request.int32 = parseInt(query['int32'], 10); if (typeof query['int64'] === 'string') request.int64 = parseInt(query['int64'], 10); @@ -381,7 +382,7 @@ export const conformanceApiPlugin: FastifyPluginAsync; if (typeof params['string'] === 'string') request.string = params['string']; if (typeof params['boolean'] === 'string') request.boolean = parseBoolean(params['boolean']); + if (typeof params['float'] === 'string') request.float = parseFloat(params['float']); if (typeof params['double'] === 'string') request.double = parseFloat(params['double']); if (typeof params['int32'] === 'string') request.int32 = parseInt(params['int32'], 10); if (typeof params['int64'] === 'string') request.int64 = parseInt(params['int64'], 10); @@ -432,6 +434,7 @@ export const conformanceApiPlugin: FastifyPluginAsync; if (typeof headers['string'] === 'string') request.string = headers['string']; if (typeof headers['boolean'] === 'string') request.boolean = parseBoolean(headers['boolean']); + if (typeof headers['float'] === 'string') request.float = parseFloat(headers['float']); if (typeof headers['double'] === 'string') request.double = parseFloat(headers['double']); if (typeof headers['int32'] === 'string') request.int32 = parseInt(headers['int32'], 10); if (typeof headers['int64'] === 'string') request.int64 = parseInt(headers['int64'], 10); @@ -450,6 +453,7 @@ export const conformanceApiPlugin: FastifyPluginAsync; + float?: IServiceResult; + double?: IServiceResult; int32?: IServiceResult; @@ -1289,6 +1314,8 @@ export interface IAnyNullable { boolean?: (boolean | null); + float?: (number | null); + double?: (number | null); int32?: (number | null); diff --git a/conformance/src/fastify/jsConformanceApiPlugin.js b/conformance/src/fastify/jsConformanceApiPlugin.js index b377fab..5e33a0c 100644 --- a/conformance/src/fastify/jsConformanceApiPlugin.js +++ b/conformance/src/fastify/jsConformanceApiPlugin.js @@ -349,6 +349,7 @@ export const jsConformanceApiPlugin = async (fastify, opts) => { const query = req.query; if (typeof query['string'] === 'string') request.string = query['string']; if (typeof query['boolean'] === 'string') request.boolean = parseBoolean(query['boolean']); + if (typeof query['float'] === 'string') request.float = parseFloat(query['float']); if (typeof query['double'] === 'string') request.double = parseFloat(query['double']); if (typeof query['int32'] === 'string') request.int32 = parseInt(query['int32'], 10); if (typeof query['int64'] === 'string') request.int64 = parseInt(query['int64'], 10); @@ -374,7 +375,7 @@ export const jsConformanceApiPlugin = async (fastify, opts) => { }); fastify.route({ - url: '/checkPath/:string/:boolean/:double/:int32/:int64/:decimal/:enum/:datetime', + url: '/checkPath/:string/:boolean/:float/:double/:int32/:int64/:decimal/:enum/:datetime', method: 'GET', schema: { response: { @@ -387,6 +388,7 @@ export const jsConformanceApiPlugin = async (fastify, opts) => { const params = req.params; if (typeof params['string'] === 'string') request.string = params['string']; if (typeof params['boolean'] === 'string') request.boolean = parseBoolean(params['boolean']); + if (typeof params['float'] === 'string') request.float = parseFloat(params['float']); if (typeof params['double'] === 'string') request.double = parseFloat(params['double']); if (typeof params['int32'] === 'string') request.int32 = parseInt(params['int32'], 10); if (typeof params['int64'] === 'string') request.int64 = parseInt(params['int64'], 10); @@ -425,6 +427,7 @@ export const jsConformanceApiPlugin = async (fastify, opts) => { const headers = req.headers; if (typeof headers['string'] === 'string') request.string = headers['string']; if (typeof headers['boolean'] === 'string') request.boolean = parseBoolean(headers['boolean']); + if (typeof headers['float'] === 'string') request.float = parseFloat(headers['float']); if (typeof headers['double'] === 'string') request.double = parseFloat(headers['double']); if (typeof headers['int32'] === 'string') request.int32 = parseInt(headers['int32'], 10); if (typeof headers['int64'] === 'string') request.int64 = parseInt(headers['int64'], 10); @@ -443,6 +446,7 @@ export const jsConformanceApiPlugin = async (fastify, opts) => { if (result.value) { if (result.value.string != null) res.header('string', result.value.string); if (result.value.boolean != null) res.header('boolean', result.value.boolean); + if (result.value.float != null) res.header('float', result.value.float); if (result.value.double != null) res.header('double', result.value.double); if (result.value.int32 != null) res.header('int32', result.value.int32); if (result.value.int64 != null) res.header('int64', result.value.int64); @@ -696,6 +700,7 @@ const jsonSchemas = [ properties: { string: { type: 'string' }, boolean: { type: 'boolean' }, + float: { type: 'number' }, double: { type: 'number' }, int32: { type: 'integer' }, int64: { type: 'integer' }, @@ -718,6 +723,7 @@ const jsonSchemas = [ properties: { string: { type: 'array', items: { type: 'string' } }, boolean: { type: 'array', items: { type: 'boolean' } }, + float: { type: 'array', items: { type: 'number' } }, double: { type: 'array', items: { type: 'number' } }, int32: { type: 'array', items: { type: 'integer' } }, int64: { type: 'array', items: { type: 'integer' } }, @@ -740,6 +746,7 @@ const jsonSchemas = [ properties: { string: { type: 'object', additionalProperties: { type: 'string' } }, boolean: { type: 'object', additionalProperties: { type: 'boolean' } }, + float: { type: 'object', additionalProperties: { type: 'number' } }, double: { type: 'object', additionalProperties: { type: 'number' } }, int32: { type: 'object', additionalProperties: { type: 'integer' } }, int64: { type: 'object', additionalProperties: { type: 'integer' } }, @@ -762,6 +769,7 @@ const jsonSchemas = [ properties: { string: { type: 'object', properties: { value: { type: 'string' }, error: { $ref: '_error' } } }, boolean: { type: 'object', properties: { value: { type: 'boolean' }, error: { $ref: '_error' } } }, + float: { type: 'object', properties: { value: { type: 'number' }, error: { $ref: '_error' } } }, double: { type: 'object', properties: { value: { type: 'number' }, error: { $ref: '_error' } } }, int32: { type: 'object', properties: { value: { type: 'integer' }, error: { $ref: '_error' } } }, int64: { type: 'object', properties: { value: { type: 'integer' }, error: { $ref: '_error' } } }, @@ -784,6 +792,7 @@ const jsonSchemas = [ properties: { string: { oneOf: [ { type: 'string' }, { type: 'null' } ] }, boolean: { oneOf: [ { type: 'boolean' }, { type: 'null' } ] }, + float: { oneOf: [ { type: 'number' }, { type: 'null' } ] }, double: { oneOf: [ { type: 'number' }, { type: 'null' } ] }, int32: { oneOf: [ { type: 'integer' }, { type: 'null' } ] }, int64: { oneOf: [ { type: 'integer' }, { type: 'null' } ] }, diff --git a/conformance/src/jsConformanceApi.js b/conformance/src/jsConformanceApi.js index d1559ee..b4d23b3 100644 --- a/conformance/src/jsConformanceApi.js +++ b/conformance/src/jsConformanceApi.js @@ -251,6 +251,7 @@ class JsConformanceApiHttpClient { const query = []; request.string == null || query.push('string=' + encodeURIComponent(request.string)); request.boolean == null || query.push('boolean=' + request.boolean.toString()); + request.float == null || query.push('float=' + encodeURIComponent(request.float.toString())); request.double == null || query.push('double=' + encodeURIComponent(request.double.toString())); request.int32 == null || query.push('int32=' + request.int32.toString()); request.int64 == null || query.push('int64=' + request.int64.toString()); @@ -286,6 +287,10 @@ class JsConformanceApiHttpClient { if (!uriPartBoolean) { return Promise.resolve(createRequiredRequestFieldError('boolean')); } + const uriPartFloat = request.float != null && encodeURIComponent(request.float.toString()); + if (!uriPartFloat) { + return Promise.resolve(createRequiredRequestFieldError('float')); + } const uriPartDouble = request.double != null && encodeURIComponent(request.double.toString()); if (!uriPartDouble) { return Promise.resolve(createRequiredRequestFieldError('double')); @@ -310,7 +315,7 @@ class JsConformanceApiHttpClient { if (!uriPartDatetime) { return Promise.resolve(createRequiredRequestFieldError('datetime')); } - const uri = `checkPath/${uriPartString}/${uriPartBoolean}/${uriPartDouble}/${uriPartInt32}/${uriPartInt64}/${uriPartDecimal}/${uriPartEnum}/${uriPartDatetime}`; + const uri = `checkPath/${uriPartString}/${uriPartBoolean}/${uriPartFloat}/${uriPartDouble}/${uriPartInt32}/${uriPartInt64}/${uriPartDecimal}/${uriPartEnum}/${uriPartDatetime}`; const fetchRequest = { method: 'GET', }; @@ -340,6 +345,9 @@ class JsConformanceApiHttpClient { if (request.boolean != null) { fetchRequest.headers['boolean'] = request.boolean.toString(); } + if (request.float != null) { + fetchRequest.headers['float'] = request.float.toString(); + } if (request.double != null) { fetchRequest.headers['double'] = request.double.toString(); } @@ -377,6 +385,10 @@ class JsConformanceApiHttpClient { if (headerValue != null) { value.boolean = parseBoolean(headerValue); } + headerValue = result.response.headers.get('float'); + if (headerValue != null) { + value.float = parseFloat(headerValue); + } headerValue = result.response.headers.get('double'); if (headerValue != null) { value.double = parseFloat(headerValue); diff --git a/dotnet-tools.json b/dotnet-tools.json index 628a8d8..462ea63 100644 --- a/dotnet-tools.json +++ b/dotnet-tools.json @@ -3,7 +3,7 @@ "isRoot": true, "tools": { "facilityconformance": { - "version": "2.30.0", + "version": "2.31.0", "commands": [ "FacilityConformance" ], diff --git a/src/Facility.CodeGen.JavaScript/JavaScriptGenerator.cs b/src/Facility.CodeGen.JavaScript/JavaScriptGenerator.cs index 661ef7c..6dc7766 100644 --- a/src/Facility.CodeGen.JavaScript/JavaScriptGenerator.cs +++ b/src/Facility.CodeGen.JavaScript/JavaScriptGenerator.cs @@ -842,7 +842,7 @@ private CodeGenOutput GenerateFastifyPluginOutput(ServiceInfo service) { ServiceTypeKind.String or ServiceTypeKind.Bytes or ServiceTypeKind.DateTime or ServiceTypeKind.ExternalEnum => "{ type: 'string' }", ServiceTypeKind.Boolean => "{ type: 'boolean' }", - ServiceTypeKind.Double or ServiceTypeKind.Decimal => "{ type: 'number' }", + ServiceTypeKind.Float or ServiceTypeKind.Double or ServiceTypeKind.Decimal => "{ type: 'number' }", ServiceTypeKind.Int32 or ServiceTypeKind.Int64 => "{ type: 'integer' }", ServiceTypeKind.Object or ServiceTypeKind.ExternalDto => "{ type: 'object', additionalProperties: true }", ServiceTypeKind.Error => "{ $ref: '_error' }", @@ -951,6 +951,7 @@ private static string RenderFieldType(ServiceTypeInfo fieldType) return fieldType.ExternalEnum!.Name; case ServiceTypeKind.Boolean: return "boolean"; + case ServiceTypeKind.Float: case ServiceTypeKind.Double: case ServiceTypeKind.Int32: case ServiceTypeKind.Int64: @@ -996,6 +997,7 @@ private static string RenderUriComponent(ServiceFieldInfo field, ServiceInfo ser case ServiceTypeKind.Int64: case ServiceTypeKind.Decimal: return $"request.{fieldName}.toString()"; + case ServiceTypeKind.Float: case ServiceTypeKind.Double: return $"encodeURIComponent(request.{fieldName}.toString())"; case ServiceTypeKind.Dto: @@ -1027,6 +1029,7 @@ private string ParseFieldValue(ServiceFieldInfo field, ServiceInfo service, stri case ServiceTypeKind.Int64: return $"parseInt({value}, 10)"; case ServiceTypeKind.Decimal: + case ServiceTypeKind.Float: case ServiceTypeKind.Double: return $"parseFloat({value})"; case ServiceTypeKind.Dto: @@ -1055,6 +1058,7 @@ private static string RenderFieldValue(ServiceFieldInfo field, ServiceInfo servi case ServiceTypeKind.Int32: case ServiceTypeKind.Int64: case ServiceTypeKind.Decimal: + case ServiceTypeKind.Float: case ServiceTypeKind.Double: return $"{value}.toString()"; case ServiceTypeKind.Dto: