Skip to content

Commit

Permalink
updated collectable items
Browse files Browse the repository at this point in the history
  • Loading branch information
theorm committed Apr 25, 2024
1 parent e95732c commit f516a2a
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 74 deletions.
36 changes: 0 additions & 36 deletions src/schema/collectable-items/response.json

This file was deleted.

18 changes: 18 additions & 0 deletions src/schema/responses/collectableItemsFind.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$ref": "baseFind.json",
"unevaluatedProperties": false,
"type": "object",
"title": "Collectable Item Find Response",
"description": "Collectable Item find response",
"additionalProperties": false,
"required": ["data"],
"properties": {
"data": {
"type": "array",
"items": {
"$ref": "../schemas/CollectableItemGroup.json"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "https://github.com/impresso/impresso-middle-layer/tree/master/src/schema/collectable-items/CollectableItemGroup.json",
"description": "Collectable item group object",
"title": "CollectableItemGroup",
"title": "Collectable Item Group",
"type": "object",
"properties": {
"itemId": {
Expand Down Expand Up @@ -31,7 +30,7 @@
"collections": {
"type": "array",
"items": {
"$ref": "https://github.com/impresso/impresso-middle-layer/tree/master/src/schema/models/collection.model.json"
"$ref": "./Collection.json"
},
"description": "Collection objects"
},
Expand Down
28 changes: 5 additions & 23 deletions src/services/collectable-items/collectable-items.schema.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,7 @@
import { ServiceSwaggerOptions } from 'feathers-swagger'
import { QueryParameter } from '../../util/openapi'
import { QueryParameter, getStandardResponses } from '../../util/openapi'
import { REGEX_UIDS } from '../../hooks/params'

const baseUserSchema = require('../../schema/models/base-user.model.json')
baseUserSchema.$id = '#/components/schemas/base-user'

const collectionSchema = require('../../schema/models/collection.model.json')
collectionSchema.$id = '#/components/schemas/collection'
collectionSchema.properties.creator.$ref = '#/components/schemas/baseUser'

const collectableItemGroupSchema = require('../../schema/collectable-items/CollectableItemGroup.json')
collectableItemGroupSchema.$id = '#/components/schemas/CollectableItemGroup'
collectableItemGroupSchema.properties.collections.items.$ref = '#/components/schemas/collection'

const collectableItemsFindResponseSchema = require('../../schema/collectable-items/response.json')
collectableItemsFindResponseSchema.$id = '#/components/schemas/findResponse'
collectableItemsFindResponseSchema.properties.data.items.$ref = '#/components/schemas/CollectableItemGroup'

const findParameters: QueryParameter[] = [
{
in: 'query',
Expand Down Expand Up @@ -89,17 +74,14 @@ const findParameters: QueryParameter[] = [
export const docs: ServiceSwaggerOptions = {
description: 'Collectable items',
securities: ['find', 'create', 'remove'],
schemas: {
collectableItemsFindResponseSchema,
baseUser: baseUserSchema,
collection: collectionSchema,
CollectableItemGroup: collectableItemGroupSchema,
},
refs: { findResponse: 'collectableItemsFindResponseSchema' },
operations: {
find: {
description: 'Find collectable items that match the given query',
parameters: findParameters,
responses: getStandardResponses({
method: 'find',
schema: 'collectableItemsFind',
}),
},
},
}
24 changes: 12 additions & 12 deletions src/services/collectable-items/collectable-items.service.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
// import { createSwaggerServiceOptions } from 'feathers-swagger';
import { optionsDisabledInPublicApi } from '../../hooks/public-api';
// import { docs } from './collectable-items.schema';
import { createSwaggerServiceOptions } from 'feathers-swagger'
import { optionsDisabledInPublicApi } from '../../hooks/public-api'
import { docs } from './collectable-items.schema'

// Initializes the `collectable-items` service on path `/collectable-items`
const createService = require('./collectable-items.class.js');
const hooks = require('./collectable-items.hooks');
const createService = require('./collectable-items.class.js')
const hooks = require('./collectable-items.hooks')

module.exports = function (app) {
const paginate = app.get('paginate');
const paginate = app.get('paginate')

const options = {
name: 'collectable-items',
paginate,
app,
};
}

// Initialize our service with any options it requires
app.use('/collectable-items', createService(options), {
...optionsDisabledInPublicApi(app),
events: [],
// disabled for now while it's not public
// docs: createSwaggerServiceOptions({ schemas: {}, docs }),
});
docs: createSwaggerServiceOptions({ schemas: {}, docs }),
})

// Get our initialized service so that we can register hooks
const service = app.service('collectable-items');
const service = app.service('collectable-items')

service.hooks(hooks);
};
service.hooks(hooks)
}

0 comments on commit f516a2a

Please sign in to comment.