@platformatic/sql-openapi
Advanced tools
Comparing version 0.6.1 to 0.7.0
@@ -64,3 +64,3 @@ 'use strict' | ||
const key = baseKey + modifier | ||
acc[key] = { type: mapSQLTypeToOpenAPIType(field.sqlType) } | ||
acc[key] = { type: mapSQLTypeToOpenAPIType(field.sqlType), enum: field.enum } | ||
} | ||
@@ -389,2 +389,61 @@ | ||
app.put('/', { | ||
schema: { | ||
body: entitySchema, | ||
querystring: { | ||
type: 'object', | ||
properties: { | ||
fields, | ||
...whereArgs | ||
}, | ||
additionalProperties: false | ||
}, | ||
response: { | ||
200: { | ||
type: 'array', | ||
items: entitySchema | ||
} | ||
} | ||
}, | ||
links: { | ||
200: entityLinks | ||
}, | ||
async handler (request, reply) { | ||
const ctx = { app: this, reply } | ||
const query = request.query | ||
const queryKeys = Object.keys(query) | ||
const where = {} | ||
for (let i = 0; i < queryKeys.length; i++) { | ||
const key = queryKeys[i] | ||
if (key.startsWith('where.')) { | ||
const [, field, modifier] = key.split('.') | ||
where[field] ||= {} | ||
let value = query[key] | ||
if (modifier === 'in' || modifier === 'nin') { | ||
// TODO handle escaping of , | ||
value = query[key].split(',') | ||
if (mapSQLTypeToOpenAPIType(entity.fields[field].sqlType) === 'integer') { | ||
value = value.map((v) => parseInt(v)) | ||
} | ||
} | ||
where[field][modifier] = value | ||
} | ||
} | ||
const res = await entity.updateMany({ | ||
input: { | ||
...request.body | ||
}, | ||
where, | ||
fields: request.query.fields, | ||
ctx | ||
}) | ||
// TODO: Should find a way to test this line | ||
// if (!res) return reply.callNotFound() | ||
reply.header('location', `${app.prefix}`) | ||
return res | ||
} | ||
}) | ||
app.delete(`/:${primaryKeyCamelcase}`, { | ||
@@ -391,0 +450,0 @@ schema: { |
{ | ||
"name": "@platformatic/sql-openapi", | ||
"version": "0.6.1", | ||
"version": "0.7.0", | ||
"description": "Map a SQL database to OpenAPI, for Fastify", | ||
@@ -8,3 +8,3 @@ "main": "index.js", | ||
"type": "git", | ||
"url": "git+https://github.com/plaformatic/platformatic.git" | ||
"url": "git+https://github.com/platformatic/platformatic.git" | ||
}, | ||
@@ -14,7 +14,7 @@ "author": "Matteo Collina <hello@matteocollina.com>", | ||
"bugs": { | ||
"url": "https://github.com/plaformatic/platformatic/issues" | ||
"url": "https://github.com/platformatic/platformatic/issues" | ||
}, | ||
"homepage": "https://github.com/plaformatic/platformatic#readme", | ||
"homepage": "https://github.com/platformatic/platformatic#readme", | ||
"devDependencies": { | ||
"@platformatic/sql-mapper": "0.6.1", | ||
"@platformatic/sql-mapper": "0.7.0", | ||
"fastify": "^4.6.0", | ||
@@ -29,3 +29,3 @@ "mercurius": "^11.0.0", | ||
"dependencies": { | ||
"@platformatic/sql-json-schema-mapper": "0.6.1", | ||
"@platformatic/sql-json-schema-mapper": "0.7.0", | ||
"@fastify/deepmerge": "^1.1.0", | ||
@@ -32,0 +32,0 @@ "@fastify/swagger": "^8.0.0", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
339796
27
12379
0
1
+ Added@platformatic/sql-json-schema-mapper@0.7.0(transitive)
- Removed@platformatic/sql-json-schema-mapper@0.6.1(transitive)