Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

odata-json-schema

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

odata-json-schema - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

example/Edm/Binary.json

2

__test__/index.js
const { generateJSONSchema } = require('../index')
generateJSONSchema('https://services.odata.org/V4/TripPinService', {
dist: './dist'
dist: './example'
})

@@ -5,8 +5,6 @@ {

"AirlineCode": {
"nullable": false,
"type": "string"
"$ref": "Edm/String"
},
"Name": {
"nullable": false,
"type": "string"
"$ref": "Edm/String"
}

@@ -13,0 +11,0 @@ },

@@ -5,15 +5,11 @@ {

"IcaoCode": {
"nullable": false,
"type": "string"
"$ref": "Edm/String"
},
"Name": {
"nullable": false,
"type": "string"
"$ref": "Edm/String"
},
"IataCode": {
"nullable": false,
"type": "string"
"$ref": "Edm/String"
},
"Location": {
"nullable": false,
"$ref": "Microsoft/OData/SampleService/Models/TripPin/AirportLocation"

@@ -20,0 +16,0 @@ }

@@ -5,3 +5,3 @@ {

"Loc": {
"nullable": false
"$ref": "Edm/GeographyPoint"
}

@@ -8,0 +8,0 @@ },

@@ -5,12 +5,9 @@ {

"CountryRegion": {
"nullable": false,
"type": "string"
"$ref": "Edm/String"
},
"Name": {
"nullable": false,
"type": "string"
"$ref": "Edm/String"
},
"Region": {
"nullable": false,
"type": "string"
"$ref": "Edm/String"
}

@@ -17,0 +14,0 @@ },

@@ -5,6 +5,5 @@ {

"Description": {
"type": "string"
"$ref": "Edm/String"
},
"OccursAt": {
"nullable": false,
"$ref": "Microsoft/OData/SampleService/Models/TripPin/EventLocation"

@@ -11,0 +10,0 @@ }

@@ -5,3 +5,3 @@ {

"BuildingInfo": {
"type": "string"
"$ref": "Edm/String"
}

@@ -8,0 +8,0 @@ },

@@ -5,16 +5,12 @@ {

"From": {
"nullable": false,
"$ref": "Microsoft/OData/SampleService/Models/TripPin/Airport"
},
"To": {
"nullable": false,
"$ref": "Microsoft/OData/SampleService/Models/TripPin/Airport"
},
"Airline": {
"nullable": false,
"$ref": "Microsoft/OData/SampleService/Models/TripPin/Airline"
},
"FlightNumber": {
"nullable": false,
"type": "string"
"$ref": "Edm/String"
}

@@ -21,0 +17,0 @@ },

@@ -5,7 +5,5 @@ {

"Address": {
"nullable": false,
"type": "string"
"$ref": "Edm/String"
},
"City": {
"nullable": false,
"$ref": "Microsoft/OData/SampleService/Models/TripPin/City"

@@ -12,0 +10,0 @@ }

@@ -20,12 +20,9 @@ {

"UserName": {
"nullable": false,
"type": "string"
"$ref": "Edm/String"
},
"FirstName": {
"nullable": false,
"type": "string"
"$ref": "Edm/String"
},
"LastName": {
"nullable": false,
"type": "string"
"$ref": "Edm/String"
},

@@ -35,3 +32,3 @@ "Emails": {

"items": {
"type": "string"
"$ref": "Edm/String"
}

@@ -49,4 +46,3 @@ },

"Concurrency": {
"nullable": false,
"type": "integer"
"$ref": "Edm/Int64"
}

@@ -72,12 +68,9 @@ },

"person": {
"nullable": false,
"$ref": "Microsoft/OData/SampleService/Models/TripPin/Person"
},
"userName": {
"nullable": false,
"type": "string"
"$ref": "Edm/String"
},
"tripId": {
"nullable": false,
"type": "integer"
"$ref": "Edm/Int32"
}

@@ -95,3 +88,2 @@ },

"person": {
"nullable": false,
"$ref": "Microsoft/OData/SampleService/Models/TripPin/Person"

@@ -111,8 +103,6 @@ }

"person": {
"nullable": false,
"$ref": "Microsoft/OData/SampleService/Models/TripPin/Person"
},
"userName": {
"nullable": false,
"type": "string"
"$ref": "Edm/String"
}

@@ -119,0 +109,0 @@ },

@@ -5,7 +5,6 @@ {

"Id": {
"nullable": false,
"type": "integer"
"$ref": "Edm/Int64"
},
"Name": {
"type": "string"
"$ref": "Edm/String"
}

@@ -12,0 +11,0 @@ },

@@ -5,15 +5,15 @@ {

"PlanItemId": {
"nullable": false,
"type": "integer"
"$ref": "Edm/Int32"
},
"ConfirmationCode": {
"type": "string"
"$ref": "Edm/String"
},
"StartsAt": {
"type": "string",
"format": "date-time"
"$ref": "Edm/DateTimeOffset"
},
"EndsAt": {
"type": "string",
"format": "date-time"
"$ref": "Edm/DateTimeOffset"
},
"Duration": {
"$ref": "Edm/Duration"
}

@@ -20,0 +20,0 @@ },

@@ -5,3 +5,3 @@ {

"SeatNumber": {
"type": "string"
"$ref": "Edm/String"
}

@@ -8,0 +8,0 @@ },

@@ -17,24 +17,21 @@ {

"TripId": {
"nullable": false,
"type": "integer"
"$ref": "Edm/Int32"
},
"ShareId": {
"$ref": "Edm/Guid"
},
"Description": {
"type": "string"
"$ref": "Edm/String"
},
"Name": {
"nullable": false,
"type": "string"
"$ref": "Edm/String"
},
"Budget": {
"nullable": false
"$ref": "Edm/Single"
},
"StartsAt": {
"nullable": false,
"type": "string",
"format": "date-time"
"$ref": "Edm/DateTimeOffset"
},
"EndsAt": {
"nullable": false,
"type": "string",
"format": "date-time"
"$ref": "Edm/DateTimeOffset"
},

@@ -44,3 +41,3 @@ "Tags": {

"items": {
"type": "string"
"$ref": "Edm/String"
}

@@ -65,3 +62,2 @@ }

"trip": {
"nullable": false,
"$ref": "Microsoft/OData/SampleService/Models/TripPin/Trip"

@@ -68,0 +64,0 @@ }

const { parseBoolean } = require('./parseBoolean');
function addNullable(schema, nullable) {
if (nullable) {
return Object.assign({
nullable: parseBoolean(nullable),
}, schema);
if (nullable && parseBoolean(nullable)) {
return {
oneOf: [schema, {
type: 'null',
}],
}
}

@@ -9,0 +11,0 @@ return schema;

const EDMPrimitivesMapping = {
Binary: {},
Boolean: { type: 'boolean' },
Byte: { type: 'integer' },
DateTime: {},
DateTimeOffset: { type: 'string', format: 'date-time' },
Decimal: { type: 'number' },
Double: { type: 'number' },
Float: { type: 'number' },
GeographyPoint: {},
Int16: { type: 'integer' },
Int32: { type: 'integer' },
Int64: { type: 'integer' },
SByte: { type: 'integer' },
Single: { type: 'number' },
String: { type: 'string' },
Time: { type: 'string', format: 'time' },
};
for (const EDMType in EDMPrimitivesMapping) {
EDMPrimitivesMapping[EDMType].$$ODataExtension = {
Name: EDMType
};
}
exports.EDMPrimitivesMapping = EDMPrimitivesMapping;

@@ -5,5 +5,11 @@ const { parseEntityType } = require('./parseEntityType');

const { bindMethods } = require('./bindMethods');
const { EDMPrimitivesMapping } = require('./EDMPrimitivesMapping');
function parseSchemas(schemas) {
const ans = {};
const ans = {
Edm: {}
};
for (const EDMType in EDMPrimitivesMapping) {
ans.Edm[EDMType] = EDMPrimitivesMapping[EDMType];
}
for (const { $: { Namespace }, ComplexType = [], EntityType = [], EnumType = [] } of schemas) {

@@ -10,0 +16,0 @@ ans[Namespace] = {};

@@ -1,2 +0,1 @@

const { EDMPrimitivesMapping } = require('./EDMPrimitivesMapping');
const { addNullable } = require('./addNullable');

@@ -13,5 +12,2 @@ const { parseFullName } = require('./parseFullName');

}
if (typeReference.startsWith('Edm.')) {
return addNullable(EDMPrimitivesMapping[typeReference.substr(4)], nullable);
}
return addNullable({

@@ -18,0 +14,0 @@ $ref: parseFullName(typeReference),

{
"name": "odata-json-schema",
"version": "0.0.2",
"version": "0.0.3",
"license": "MIT",

@@ -5,0 +5,0 @@ "author": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc