@api-platform/api-doc-parser
Advanced tools
Comparing version 0.16.0 to 0.16.1
@@ -9,3 +9,5 @@ import type { Resource } from "./Resource.js"; | ||
arrayType?: FieldType; | ||
enum?: string[] | number[]; | ||
enum?: { | ||
[key: string | number]: string | number; | ||
}; | ||
reference?: string | Resource; | ||
@@ -12,0 +14,0 @@ embedded?: Resource; |
@@ -57,4 +57,12 @@ import { __awaiter } from "tslib"; | ||
: null, | ||
// Object.values is used because the array is annotated: it contains the __meta symbol used by jsonref. | ||
enum: property.enum ? Object.values(property.enum) : null, | ||
enum: property.enum | ||
? Object.fromEntries( | ||
// Object.values is used because the array is annotated: it contains the __meta symbol used by jsonref. | ||
Object.values(property.enum).map((enumValue) => [ | ||
typeof enumValue === "string" | ||
? inflection.humanize(enumValue) | ||
: enumValue, | ||
enumValue, | ||
])) | ||
: null, | ||
reference: null, | ||
@@ -61,0 +69,0 @@ embedded: null, |
@@ -35,3 +35,2 @@ import get from "lodash.get"; | ||
const fields = fieldNames.map((fieldName) => { | ||
var _a; | ||
const property = properties[fieldName]; | ||
@@ -42,3 +41,10 @@ return new Field(fieldName, { | ||
type: getType(get(property, "type", ""), get(property, "format", "")), | ||
enum: (_a = property.enum) !== null && _a !== void 0 ? _a : null, | ||
enum: property.enum | ||
? Object.fromEntries(property.enum.map((enumValue) => [ | ||
typeof enumValue === "string" | ||
? inflection.humanize(enumValue) | ||
: enumValue, | ||
enumValue, | ||
])) | ||
: null, | ||
reference: null, | ||
@@ -45,0 +51,0 @@ embedded: null, |
{ | ||
"name": "@api-platform/api-doc-parser", | ||
"version": "0.16.0", | ||
"version": "0.16.1", | ||
"description": "Transform an API documentation (Hydra, OpenAPI, GraphQL) in an intermediate representation that can be used for various tasks such as creating smart API clients, scaffolding code or building administration interfaces.", | ||
@@ -5,0 +5,0 @@ "files": [ |
@@ -39,3 +39,3 @@ import { assignSealed } from "./utils/assignSealed.js"; | ||
arrayType?: FieldType; | ||
enum?: string[] | number[]; | ||
enum?: { [key: string | number]: string | number }; | ||
reference?: string | Resource; | ||
@@ -42,0 +42,0 @@ embedded?: Resource; |
@@ -519,3 +519,3 @@ import handleJson from "./handleJson.js"; | ||
description: "The publication format of the book.", | ||
enum: ["AudiobookFormat", "EBook", "Paperback", "Hardcover"], | ||
enum: ["AUDIOBOOK_FORMAT", "E_BOOK", "PAPERBACK", "HARDCOVER"], | ||
}, | ||
@@ -577,3 +577,3 @@ publicationDate: { | ||
description: "The publication format of the book.", | ||
enum: ["AudiobookFormat", "EBook", "Paperback", "Hardcover"], | ||
enum: ["AUDIOBOOK_FORMAT", "E_BOOK", "PAPERBACK", "HARDCOVER"], | ||
}, | ||
@@ -710,3 +710,8 @@ publicationDate: { | ||
arrayType: null, | ||
enum: ["AudiobookFormat", "EBook", "Paperback", "Hardcover"], | ||
enum: { | ||
"Audiobook format": "AUDIOBOOK_FORMAT", | ||
"E book": "E_BOOK", | ||
Paperback: "PAPERBACK", | ||
Hardcover: "HARDCOVER", | ||
}, | ||
reference: null, | ||
@@ -835,3 +840,8 @@ embedded: null, | ||
arrayType: null, | ||
enum: ["AudiobookFormat", "EBook", "Paperback", "Hardcover"], | ||
enum: { | ||
"Audiobook format": "AUDIOBOOK_FORMAT", | ||
"E book": "E_BOOK", | ||
Paperback: "PAPERBACK", | ||
Hardcover: "HARDCOVER", | ||
}, | ||
reference: null, | ||
@@ -934,3 +944,8 @@ embedded: null, | ||
arrayType: null, | ||
enum: ["AudiobookFormat", "EBook", "Paperback", "Hardcover"], | ||
enum: { | ||
"Audiobook format": "AUDIOBOOK_FORMAT", | ||
"E book": "E_BOOK", | ||
Paperback: "PAPERBACK", | ||
Hardcover: "HARDCOVER", | ||
}, | ||
reference: null, | ||
@@ -937,0 +952,0 @@ embedded: null, |
@@ -77,4 +77,13 @@ import { parse as dereference } from "jsonref"; | ||
: null, | ||
// Object.values is used because the array is annotated: it contains the __meta symbol used by jsonref. | ||
enum: property.enum ? Object.values(property.enum) : null, | ||
enum: property.enum | ||
? Object.fromEntries( | ||
// Object.values is used because the array is annotated: it contains the __meta symbol used by jsonref. | ||
Object.values<string | number>(property.enum).map((enumValue) => [ | ||
typeof enumValue === "string" | ||
? inflection.humanize(enumValue) | ||
: enumValue, | ||
enumValue, | ||
]) | ||
) | ||
: null, | ||
reference: null, | ||
@@ -81,0 +90,0 @@ embedded: null, |
@@ -332,3 +332,3 @@ import handleJson from "./handleJson.js"; | ||
description: "The publication format of the book.", | ||
enum: ["AudiobookFormat", "EBook", "Paperback", "Hardcover"], | ||
enum: ["AUDIOBOOK_FORMAT", "E_BOOK", "PAPERBACK", "HARDCOVER"], | ||
}, | ||
@@ -449,3 +449,8 @@ publicationDate: { | ||
embedded: null, | ||
enum: ["AudiobookFormat", "EBook", "Paperback", "Hardcover"], | ||
enum: { | ||
"Audiobook format": "AUDIOBOOK_FORMAT", | ||
"E book": "E_BOOK", | ||
Paperback: "PAPERBACK", | ||
Hardcover: "HARDCOVER", | ||
}, | ||
required: true, | ||
@@ -452,0 +457,0 @@ description: "The publication format of the book.", |
@@ -63,3 +63,12 @@ import get from "lodash.get"; | ||
), | ||
enum: property.enum ?? null, | ||
enum: property.enum | ||
? Object.fromEntries( | ||
property.enum.map((enumValue: string | number) => [ | ||
typeof enumValue === "string" | ||
? inflection.humanize(enumValue) | ||
: enumValue, | ||
enumValue, | ||
]) | ||
) | ||
: null, | ||
reference: null, | ||
@@ -66,0 +75,0 @@ embedded: null, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
275109
7050