Skip to content

Ref(api-specification): refactoring folder structure for occupation group relations api-specification definetion#483

Merged
irumvanselme merged 5 commits intomainfrom
fix/refactoring_folder_structure_for_occupation_group_api_specification
Mar 30, 2026
Merged

Ref(api-specification): refactoring folder structure for occupation group relations api-specification definetion#483
irumvanselme merged 5 commits intomainfrom
fix/refactoring_folder_structure_for_occupation_group_api_specification

Conversation

@C5rogers
Copy link
Copy Markdown

@C5rogers C5rogers commented Mar 4, 2026

  • This pull request have a change on the api-specification of OccupationGroup for relations api separeting based on there hierarchy

@C5rogers C5rogers self-assigned this Mar 4, 2026
@C5rogers C5rogers added the documentation Improvements or additions to documentation label Mar 4, 2026
@C5rogers C5rogers requested a review from Copilot March 4, 2026 08:46
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the api-specifications for OccupationGroup relation endpoints by splitting relation-specific pieces into relations/parent and relations/children folders and updating imports/exports accordingly.

Changes:

  • Update relation schema/test imports to reflect the new relations/* folder structure.
  • Add new relation-specific enum modules (relations/parent/enum.ts, relations/children/enum.ts) and export them from occupationGroup/index.ts.
  • Update the occupationGroup module export snapshot to include the new enum exports.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
backend/globalConfig.json Adds a hard-coded local MongoDB URI config file.
api-specifications/src/esco/occupationGroup/relations/parent/schema.GET.parent.response.ts Fixes _baseResponseSchema import path after moving under relations/parent.
api-specifications/src/esco/occupationGroup/relations/parent/schema.GET.parent.response.test.ts Updates imports to reference occupationGroup root module/enums/regex after refactor.
api-specifications/src/esco/occupationGroup/relations/parent/enum.ts Introduces parent-relation enum namespace and error codes.
api-specifications/src/esco/occupationGroup/relations/children/schema.GET.child.response.ts Fixes _baseChildrenResponseSchema import path after moving under relations/children.
api-specifications/src/esco/occupationGroup/relations/children/schema.GET.child.response.test.ts Updates imports to reference occupationGroup root module/enums/regex after refactor.
api-specifications/src/esco/occupationGroup/relations/children/enum.ts Introduces children-relation enum namespace and error codes.
api-specifications/src/esco/occupationGroup/index.ts Exposes moved schemas and newly added ParentEnums/ChildrenEnums via the main module export.
api-specifications/src/esco/occupationGroup/snapshots/index.test.ts.snap Snapshot update to include the new exported enum namespaces.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread backend/globalConfig.json Outdated
@@ -0,0 +1 @@
{"mongoUri":"mongodb://127.0.0.1:24780/"} No newline at end of file
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

backend/globalConfig.json introduces a hard-coded local MongoDB URI. This file doesn’t appear to be referenced anywhere in backend/src (config is read from env elsewhere), and committing environment-specific connection strings can cause confusion in CI/prod. Consider removing this file from the repo (or replacing it with a documented example like globalConfig.example.json) and loading the URI from environment variables; if it must exist locally, add it to .gitignore.

Suggested change
{"mongoUri":"mongodb://127.0.0.1:24780/"}
{"mongoUri":"YOUR_MONGODB_URI_HERE"}

Copilot uses AI. Check for mistakes.
Comment on lines +2 to +23

namespace OccupationGroupParentEnums {
export enum ObjectTypes {
ISCOGroup = CommonGroupTypes.ISCOGroup,
LocalGroup = CommonGroupTypes.LocalGroup,
}
export namespace Relations {
export namespace Parent {
export enum ObjectTypes {
ISCOGroup = CommonGroupTypes.ISCOGroup,
LocalGroup = CommonGroupTypes.LocalGroup,
}
}
export namespace Children {
export enum ObjectTypes {
ISCOGroup = CommonGroupTypes.ISCOGroup,
LocalGroup = CommonGroupTypes.LocalGroup,
ESCOOccupation = CommonGroupTypes.ESCOOccupation,
LocalOccupation = CommonGroupTypes.LocalOccupation,
}
}
}
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This new file duplicates constants already defined in api-specifications/src/esco/occupationGroup/enums.ts (e.g., Relations.Parent.ObjectTypes and Relations.Children.ObjectTypes) and also duplicates Relations.Children.ObjectTypes again in OccupationGroupChildrenEnums. Having multiple sources of truth for the same enum values/error codes is likely to drift over time. Consider consolidating to a single definition (e.g., export the relation enums from one module and import/re-export them where needed) and removing the duplicated enum blocks here.

Suggested change
namespace OccupationGroupParentEnums {
export enum ObjectTypes {
ISCOGroup = CommonGroupTypes.ISCOGroup,
LocalGroup = CommonGroupTypes.LocalGroup,
}
export namespace Relations {
export namespace Parent {
export enum ObjectTypes {
ISCOGroup = CommonGroupTypes.ISCOGroup,
LocalGroup = CommonGroupTypes.LocalGroup,
}
}
export namespace Children {
export enum ObjectTypes {
ISCOGroup = CommonGroupTypes.ISCOGroup,
LocalGroup = CommonGroupTypes.LocalGroup,
ESCOOccupation = CommonGroupTypes.ESCOOccupation,
LocalOccupation = CommonGroupTypes.LocalOccupation,
}
}
}
import OccupationGroupEnums from "../../enums";
namespace OccupationGroupParentEnums {
export enum ObjectTypes {
ISCOGroup = CommonGroupTypes.ISCOGroup,
LocalGroup = CommonGroupTypes.LocalGroup,
}
export import Relations = OccupationGroupEnums.Relations;

Copilot uses AI. Check for mistakes.
Comment on lines +1 to +3
import { ObjectTypes as CommonGroupTypes } from "../../../common/objectTypes";

namespace OccupationGroupChildrenEnums {
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The filename enum.ts is inconsistent with the existing convention in this repo for enum modules (commonly enums.ts, including other relation enum modules). Renaming to enums.ts would improve discoverability and consistency across api-specifications/src/esco/**/relations/** folders.

Copilot uses AI. Check for mistakes.
Comment on lines +56 to +63
export import Schemas = OccupationGroupSchemas;
export import Patterns = OccupationGroupRegexes;
export import ParentEnums = OccupationGroupParentEnums;
export import ChildrenEnums = OccupationGroupChildrenEnums;
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OccupationGroupAPISpecs now exports both Enums (which already contains Relations.Parent/Children enums) and the new ParentEnums/ChildrenEnums. This creates two parallel public enum hierarchies for the same concepts, which is easy for API consumers to misuse and hard to keep in sync. Consider either (1) moving the relation enums out of ./enums.ts and re-exporting them from a single place, or (2) not exporting ParentEnums/ChildrenEnums and keeping Enums.Relations.* as the only supported path.

Copilot uses AI. Check for mistakes.
Comment thread backend/globalConfig.json Outdated
@@ -0,0 +1 @@
{"mongoUri":"mongodb://127.0.0.1:24780/"} No newline at end of file
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change adds backend/globalConfig.json, but the PR description is about refactoring the api-specifications folder structure for OccupationGroup relations. If globalConfig.json is unrelated, it should be removed from this PR to keep the change scoped and easier to review.

Copilot uses AI. Check for mistakes.
Comment thread backend/globalConfig.json Outdated
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file, should not be commited

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +13 to +16
export enum ErrorCodes {
INVALID_LIMIT_PARAMETER = "INVALID_LIMIT_PARAMETER",
INVALID_NEXT_CURSOR_PARAMETER = "INVALID_NEXT_CURSOR_PARAMETER",
}
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OccupationGroupParentEnums duplicates values that already exist in OccupationGroupEnums (e.g. object types and the shared 400 error codes). This creates a drift risk if one set is updated without the other. Prefer re-exporting the existing enums (or a shared/common enum) instead of redefining the same members here.

Suggested change
export enum ErrorCodes {
INVALID_LIMIT_PARAMETER = "INVALID_LIMIT_PARAMETER",
INVALID_NEXT_CURSOR_PARAMETER = "INVALID_NEXT_CURSOR_PARAMETER",
}
export import ErrorCodes = OccupationGroupEnums.GET.Response.Status400.ErrorCodes;

Copilot uses AI. Check for mistakes.
ISCOGroup = CommonGroupTypes.ISCOGroup,
LocalGroup = CommonGroupTypes.LocalGroup,
}
export import Relations = OccupationGroupEnums.Relations;
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

export import Relations = OccupationGroupEnums.Relations; re-exports all relation enums (including children) from within the parent-specific enum module, which makes this module’s API broader and potentially misleading. Consider removing this re-export or narrowing it to only the parent-related types so ParentEnums stays focused on the parent relation.

Suggested change
export import Relations = OccupationGroupEnums.Relations;

Copilot uses AI. Check for mistakes.
Comment on lines +4 to +16
export enum ObjectTypes {
ISCOGroup = CommonGroupTypes.ISCOGroup,
LocalGroup = CommonGroupTypes.LocalGroup,
ESCOOccupation = CommonGroupTypes.ESCOOccupation,
LocalOccupation = CommonGroupTypes.LocalOccupation,
}
export namespace GET {
export namespace Response {
export namespace Status400 {
export enum ErrorCodes {
INVALID_LIMIT_PARAMETER = "INVALID_LIMIT_PARAMETER",
INVALID_NEXT_CURSOR_PARAMETER = "INVALID_NEXT_CURSOR_PARAMETER",
}
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OccupationGroupChildrenEnums repeats enum members that already exist in OccupationGroupEnums.Relations.Children.ObjectTypes and the shared 400 error codes. Duplicating these constants across modules increases maintenance overhead and can lead to inconsistent values over time. Prefer re-exporting from a single source of truth where possible.

Copilot uses AI. Check for mistakes.
@irumvanselme irumvanselme force-pushed the fix/refactoring_folder_structure_for_occupation_group_api_specification branch from 0c15830 to da865d5 Compare March 23, 2026 13:06
Comment thread backend/src/validator.ts
Comment on lines +57 to +59
OccupationGroupAPISpecs.GETDetailAPISpecs.GETDetailAPISpecs.Schemas.Response.Payload,
OccupationGroupAPISpecs.GETDetailAPISpecs.GETDetailAPISpecs.Schemas.Response.Payload.$id
);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: An incorrect property access path ...GETDetailAPISpecs.GETDetailAPISpecs... will cause a TypeError on application startup because the nested GETDetailAPISpecs property is undefined.
Severity: CRITICAL

Suggested Fix

Remove the redundant .GETDetailAPISpecs from the property access chain in both backend/src/validator.ts and backend/openapi/generateOpenApiDoc.ts. The correct path should be OccupationGroupAPISpecs.GETDetailAPISpecs.Schemas....

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: backend/src/validator.ts#L57-L59

Potential issue: A refactoring of the API specifications introduced an incorrect
property access path. The code attempts to access
`OccupationGroupAPISpecs.GETDetailAPISpecs.GETDetailAPISpecs` in
`backend/src/validator.ts` and `backend/openapi/generateOpenApiDoc.ts`. However, the
correct namespace structure is `OccupationGroupAPISpecs.GETDetailAPISpecs`, which does
not contain a nested `GETDetailAPISpecs` property. This results in an attempt to access
a property on an `undefined` value, which will throw a `TypeError` when the modules are
loaded. Because this error occurs during application initialization, the backend server
will fail to start.

Did we get this right? 👍 / 👎 to inform future reviews.

@irumvanselme irumvanselme force-pushed the fix/refactoring_folder_structure_for_occupation_group_api_specification branch from 17be0d0 to 4ba2cbe Compare March 30, 2026 07:37
@irumvanselme irumvanselme merged commit 257fab9 into main Mar 30, 2026
13 checks passed
@irumvanselme irumvanselme deleted the fix/refactoring_folder_structure_for_occupation_group_api_specification branch March 30, 2026 07:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants