Skip to content

Commit

Permalink
fix(repository-json-schema): fix $ref typo (#963)
Browse files Browse the repository at this point in the history
* fix(repository-json-schema): fix $ref typo

* fix(repository-json-schema): fix README
  • Loading branch information
shimks committed Feb 6, 2018
1 parent a2368ce commit a438729
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 9 deletions.
Expand Up @@ -325,7 +325,7 @@ describe('Routing metadata for parameters', () => {
type: 'string',
},
foo: {
$ref: '#definitions/Foo',
$ref: '#/definitions/Foo',
},
},
});
Expand Down
1 change: 1 addition & 0 deletions packages/repository-json-schema/README.md
Expand Up @@ -30,6 +30,7 @@ The value of `jsonSchema` will be:

```json
{
"title": "MyModel",
"properties": {
"name": {
"type": "string"
Expand Down
2 changes: 1 addition & 1 deletion packages/repository-json-schema/src/build-schema.ts
Expand Up @@ -101,7 +101,7 @@ export function metaToJsonProperty(meta: PropertyDefinition): JsonDefinition {
}

const propDef = isComplexType(ctor)
? {$ref: `#definitions/${ctor.name}`}
? {$ref: `#/definitions/${ctor.name}`}
: {type: ctor.name.toLowerCase()};

if (meta.array) {
Expand Down
Expand Up @@ -139,7 +139,7 @@ describe('build-schema', () => {
const jsonSchema = modelToJsonSchema(TestModel);
expect(jsonSchema.properties).to.deepEqual({
cusType: {
$ref: '#definitions/CustomType',
$ref: '#/definitions/CustomType',
},
});
expect(jsonSchema).to.not.have.key('definitions');
Expand All @@ -159,7 +159,7 @@ describe('build-schema', () => {
const jsonSchema = modelToJsonSchema(TestModel);
expect(jsonSchema.properties).to.deepEqual({
cusType: {
$ref: '#definitions/CustomType',
$ref: '#/definitions/CustomType',
},
});
expect(jsonSchema.definitions).to.deepEqual({
Expand Down Expand Up @@ -195,7 +195,7 @@ describe('build-schema', () => {
const schemaDefs = jsonSchema.definitions;
expect(schemaProps).to.deepEqual({
cusBar: {
$ref: '#definitions/CustomTypeBar',
$ref: '#/definitions/CustomTypeBar',
},
});
expect(schemaDefs).to.deepEqual({
Expand All @@ -213,7 +213,7 @@ describe('build-schema', () => {
prop: {
type: 'array',
items: {
$ref: '#definitions/CustomTypeFoo',
$ref: '#/definitions/CustomTypeFoo',
},
},
},
Expand Down Expand Up @@ -254,7 +254,7 @@ describe('build-schema', () => {
cusArr: {
type: 'array',
items: {
$ref: '#definitions/CustomType',
$ref: '#/definitions/CustomType',
},
},
});
Expand Down
Expand Up @@ -63,7 +63,7 @@ describe('build-schema', () => {
it('converts complex types', () => {
class CustomType {}
expect(metaToJsonProperty({type: CustomType})).to.eql({
$ref: '#definitions/CustomType',
$ref: '#/definitions/CustomType',
});
});

Expand All @@ -78,7 +78,7 @@ describe('build-schema', () => {
class CustomType {}
expect(metaToJsonProperty({array: true, type: CustomType})).to.eql({
type: 'array',
items: {$ref: '#definitions/CustomType'},
items: {$ref: '#/definitions/CustomType'},
});
});
});
Expand Down

0 comments on commit a438729

Please sign in to comment.