Skip to content

Commit

Permalink
fix: resolver issues when other files are in dir
Browse files Browse the repository at this point in the history
  • Loading branch information
acunniffe committed Mar 21, 2022
1 parent 24b5dc9 commit 393753a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
7 changes: 6 additions & 1 deletion src/workflows/file-resolvers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,12 @@ export async function resolveResourceVersion(
);

const resourceDir = path.join(resources, resourceNameLowerCase);
const versions = await fs.readdir(resourceDir);
const isDirectory = (await fs.lstat(resourceDir)).isDirectory();
const versions = isDirectory
? (await fs.readdir(resourceDir)).filter((name) =>
Boolean(name.match(/\d\d\d\d-\d\d-\d\d/)),
)
: [];

const matchingDate =
resourceVersion !== "latest"
Expand Down
9 changes: 3 additions & 6 deletions src/workflows/templates/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export function buildItemResponseSchema(
data: {
type: "object",
description: `${resourceName} resource object`,
required: ["id", "type"],
properties: {
id: idSchema,
type: refs.schemas.types,
Expand Down Expand Up @@ -40,6 +41,7 @@ export function buildCollectionResponseSchema(
type: "array",
items: {
type: "object",
required: ["id", "type"],
properties: {
id: idSchema,
type: refs.schemas.types,
Expand All @@ -62,6 +64,7 @@ export function buildCreateRequestSchema(
): OpenAPIV3.SchemaObject {
return {
type: "object",
required: ["id", "type"],
properties: {
id: {
type: "string",
Expand All @@ -71,9 +74,6 @@ export function buildCreateRequestSchema(
attributes: {
$ref: `#/components/schemas/${titleResourceName}CreateAttributes`,
},
relationships: {
$ref: `#/components/schemas/${titleResourceName}Relationships`,
},
},
additionalProperties: false,
};
Expand All @@ -93,9 +93,6 @@ export function buildUpdateRequestSchema(
attributes: {
$ref: `#/components/schemas/${titleResourceName}UpdateAttributes`,
},
relationships: {
$ref: `#/components/schemas/${titleResourceName}Relationships`,
},
},
additionalProperties: false,
};
Expand Down

0 comments on commit 393753a

Please sign in to comment.