@oslo-flanders/swagger-generator 1.3.0 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -385,16 +385,19 @@ let SwaggerGenerationService = class SwaggerGenerationService {
385
385
  const requiredProperties = properties
386
386
  ? Object.keys(properties)
387
387
  : undefined;
388
- /* Primitive datatypes are objects with properties */
389
- let item = {};
390
- if ([...core_1.DataTypes.values()].includes(attributeDatatypeId)) {
391
- item = {
388
+ const isPrimitive = [...core_1.DataTypes.values()].includes(attributeDatatypeId);
389
+ let item;
390
+ if (isPrimitive) {
391
+ /* Wrap primitive property in its own named schema to avoid naming collisions */
392
+ const schemaName = `${label}.${attributeLabel}`;
393
+ schemas[schemaName] = {
394
+ title: schemaName,
392
395
  type: 'object',
393
396
  description: description,
394
397
  properties: properties,
395
398
  required: requiredProperties,
396
399
  };
397
- /* Schema references are $ref, not objects */
400
+ item = { $ref: `#/components/schemas/${schemaName}` };
398
401
  }
399
402
  else {
400
403
  item = properties;
@@ -403,7 +406,7 @@ let SwaggerGenerationService = class SwaggerGenerationService {
403
406
  /* minItems must be 1, empty arrays are removed by not including the attribute, even if minCount == 0 */
404
407
  attributes[label][attributeLabel] = {
405
408
  type: 'array',
406
- description: `Lijst van ${attributeDatatypeLabel} items.`,
409
+ description: `${description} Lijst van ${attributeDatatypeLabel} items.`,
407
410
  items: item,
408
411
  minItems: Math.max(parseInt(attributeMinCount), 1),
409
412
  maxItems: attributeMaxCount == '*'
@@ -6,9 +6,9 @@ const core_1 = require("@oslo-flanders/core");
6
6
  /* eslint-disable max-len */
7
7
  const Properties = new Map([
8
8
  [core_1.ns.rdf('langString').value, { '@value': { type: 'string' }, '@language': { type: 'string', pattern: '^nl$' } }],
9
- [core_1.ns.rdfs('Literal').value, { '@value': { type: 'string' } }],
9
+ [core_1.ns.rdfs('Literal').value, { '@value': { type: 'string' }, '@type': { type: 'string' } }],
10
10
  [core_1.ns.xsd('string').value, { '@value': { type: 'string' } }],
11
- [core_1.ns.xsd('anyURI').value, { '@id': { type: 'string', format: 'uri' } }],
11
+ [core_1.ns.xsd('anyURI').value, { '@id': { type: 'string', format: 'uri' }, '@type': { type: 'string', pattern: '^AnyURI$' } }],
12
12
  [core_1.ns.xsd('dateTime').value, { '@value': { type: 'string', format: 'date-time' }, '@type': { type: 'string', pattern: '^DateTime$' } }],
13
13
  [core_1.ns.xsd('date').value, { '@value': { type: 'string', format: 'date' }, '@type': { type: 'string', pattern: '^Date$' } }],
14
14
  [core_1.ns.xsd('boolean').value, { '@value': { type: 'boolean' }, '@type': { type: 'string', pattern: '^Boolean$' } }],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oslo-flanders/swagger-generator",
3
- "version": "1.3.0",
3
+ "version": "1.4.0",
4
4
  "description": "Generate OpenAPI Swagger YAML documentation.",
5
5
  "author": "Digitaal Vlaanderen <https://data.vlaanderen.be/id/organisatie/OVO002949>",
6
6
  "homepage": "https://github.com/informatievlaanderen/OSLO-UML-Transformer/tree/main/packages/oslo-generator-swagger#readme",