Skip to content

Commit

Permalink
fix: remove getSchema from schema creation
Browse files Browse the repository at this point in the history
  • Loading branch information
ivan-tymoshenko committed Jun 15, 2022
1 parent bf12b12 commit ee5ae7b
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 21 deletions.
18 changes: 9 additions & 9 deletions test/schema-feature.test.js
Expand Up @@ -615,15 +615,15 @@ test('Get schema anyway should not add `properties` if allOf is present', t => {
second: { type: 'number' }
}
},
fastify.getSchema('first')
{ $ref: 'first' }
]
})

fastify.get('/', {
handler: () => {},
schema: {
querystring: fastify.getSchema('second'),
response: { 200: fastify.getSchema('second') }
querystring: { $ref: 'second' },
response: { 200: { $ref: 'second' } }
}
})

Expand Down Expand Up @@ -652,15 +652,15 @@ test('Get schema anyway should not add `properties` if oneOf is present', t => {
second: { type: 'number' }
}
},
fastify.getSchema('first')
{ $ref: 'first' }
]
})

fastify.get('/', {
handler: () => {},
schema: {
querystring: fastify.getSchema('second'),
response: { 200: fastify.getSchema('second') }
querystring: { $ref: 'second' },
response: { 200: { $ref: 'second' } }
}
})

Expand Down Expand Up @@ -689,15 +689,15 @@ test('Get schema anyway should not add `properties` if anyOf is present', t => {
second: { type: 'number' }
}
},
fastify.getSchema('first')
{ $ref: 'first' }
]
})

fastify.get('/', {
handler: () => {},
schema: {
querystring: fastify.getSchema('second'),
response: { 200: fastify.getSchema('second') }
querystring: { $ref: 'second' },
response: { 200: { $ref: 'second' } }
}
})

Expand Down
18 changes: 9 additions & 9 deletions test/schema-special-usage.test.js
Expand Up @@ -322,7 +322,7 @@ test("serializer read validator's schemas", t => {
fastify.get('/', {
schema: {
response: {
'2xx': ajvInstance.getSchema('http://example.com/schemas/ref').schema
'2xx': { $ref: 'http://example.com/schemas/ref' }
}
},
handler (req, res) { res.send({ hello: 'world', evict: 'this' }) }
Expand Down Expand Up @@ -364,9 +364,9 @@ test('setSchemaController in a plugin', t => {
fastify.register(schemaPlugin)
fastify.get('/', {
schema: {
query: ajvInstance.getSchema('urn:schema:ref').schema,
query: { $ref: 'urn:schema:ref' },
response: {
'2xx': ajvInstance.getSchema('urn:schema:ref').schema
'2xx': { $ref: 'urn:schema:ref' }
}
},
handler (req, res) {
Expand Down Expand Up @@ -534,9 +534,9 @@ test('setSchemaController in a plugin with head routes', t => {
fastify.register(schemaPlugin)
fastify.get('/', {
schema: {
query: ajvInstance.getSchema('urn:schema:ref').schema,
query: { $ref: 'urn:schema:ref' },
response: {
'2xx': ajvInstance.getSchema('urn:schema:ref').schema
'2xx': { $ref: 'urn:schema:ref' }
}
},
handler (req, res) {
Expand Down Expand Up @@ -614,9 +614,9 @@ test('multiple refs with the same ids', t => {

fastify.head('/', {
schema: {
query: refSchema,
query: { $ref: 'urn:schema:ref' },
response: {
'2xx': refSchema
'2xx': { $ref: 'urn:schema:ref' }
}
},
handler (req, res) {
Expand All @@ -626,9 +626,9 @@ test('multiple refs with the same ids', t => {

fastify.get('/', {
schema: {
query: refSchema,
query: { $ref: 'urn:schema:ref' },
response: {
'2xx': refSchema
'2xx': { $ref: 'urn:schema:ref' }
}
},
handler (req, res) {
Expand Down
6 changes: 3 additions & 3 deletions test/schema-validation.test.js
Expand Up @@ -125,7 +125,7 @@ test('External AJV instance', t => {
schema: {
body: schemaCRefToB,
response: {
'2xx': ajv.getSchema('urn:schema:response').schema
'2xx': { $ref: 'urn:schema:response' }
}
}
})
Expand Down Expand Up @@ -290,9 +290,9 @@ test('Triple $ref with a simple $id', t => {
fastify.post('/', {
handler (req, reply) { reply.send({ foo: 105, bar: 'foo' }) },
schema: {
body: ajv.getSchema('urn:schema:request').schema,
body: { $ref: 'urn:schema:request' },
response: {
'2xx': ajv.getSchema('urn:schema:response').schema
'2xx': { $ref: 'urn:schema:response' }
}
}
})
Expand Down

0 comments on commit ee5ae7b

Please sign in to comment.