Skip to content

Duplicated object

Description

Duplicated objects in OpenAPI or GraphQL schemas can lead to maintenance difficulties, increased complexity, data inconsistencies, performance issues, integration challenges, and documentation problems. This redundancy complicates API management and usage.

Remediation

Remove duplicated objects from the schema.

GraphQL Specific

Apollo In Apollo framework, ensure that your GraphQL schema definitions are modularized and use schema stitching or type extensions to avoid duplication. Employ tools like Apollo's schema validation to detect and merge duplicate types and resolvers, streamlining your API and improving maintainability.
Yoga In the Yoga framework, ensure that your schema definitions are modular and leverage schema stitching or directives to avoid duplication. Refactor any repeated types, fields, or resolvers to maintain a single source of truth, which simplifies maintenance and prevents inconsistencies.
Awsappsync In AWS AppSync, ensure that your GraphQL schema is designed with single sources of truth for object types and avoid duplicating type definitions. Utilize schema stitching or modularization to share common types across different schema parts. Regularly refactor your schema to merge or alias duplicated objects, and consider implementing schema validation tools to detect and prevent duplication during development.
Graphqlgo In the GraphQLGo framework, ensure that your schema definitions are modular and leverage schema stitching to combine them. Avoid defining the same types, fields, or resolvers multiple times across different parts of your schema. Utilize GraphQL directives, interfaces, or unions to create reusable components. Regularly refactor your schema to merge or abstract duplicated elements, and consider using schema validation tools to detect and resolve duplications early in the development process.
Graphqlruby In the GraphQL-Ruby framework, ensure that types, fields, and resolvers are defined only once and reused across the schema. Utilize modules or Ruby classes to encapsulate common structures and logic, and apply the DRY (Don't Repeat Yourself) principle to avoid duplication. Regularly refactor your schema to merge similar types and fields, and consider using interfaces or unions for shared functionality. This will help maintain a clean and efficient codebase, reduce potential errors, and simplify both development and API consumption.
Hasura In Hasura, ensure that your GraphQL schema is designed with reusable fragments and input types to avoid duplication. Regularly refactor your schema to merge similar types and use abstract types like interfaces or unions to handle overlapping fields. This will help maintain a clean and efficient API structure.
Agoo Consolidate duplicated objects in Agoo framework schemas to streamline API management and reduce complexity.
Ariadne Consolidate duplicated types in Ariadne schemas by defining shared types and reusing them across different parts of the schema to ensure consistency and simplify maintenance.
Caliban Refactor the schema to eliminate duplicated objects by using shared types or interfaces in the Caliban framework.
Dgraph Consolidate schema definitions to eliminate duplicated objects in Dgraph, ensuring a single source of truth for each entity to improve maintainability and consistency.
Dianajl Refactor the schema to eliminate duplicated objects by consolidating them into reusable components or fragments, ensuring consistency and simplifying maintenance in the DianaJL framework engine.
Directus Consolidate and reuse schema definitions to eliminate duplicated objects in Directus, ensuring a more maintainable and efficient API structure.
Flutter Optimize widget rebuilds by using const constructors and the const keyword to improve performance in the Flutter framework.
Graphene Refactor your Graphene schema to eliminate duplicated types by using shared interfaces or abstract types to promote reusability and consistency.
Graphqlapiforwp Consolidate duplicated objects in GraphQL schemas within the GraphQL API for WordPress framework to streamline maintenance, reduce complexity, and ensure data consistency.
Graphqlgophergo Consolidate duplicated objects in GraphQL schemas to streamline API management and reduce complexity.
Graphqljava Consolidate duplicated objects in GraphQL schemas by defining shared types and reusing them across queries and mutations to simplify maintenance and improve consistency in the graphql-java framework.
Graphqlphp Consolidate duplicated types and fields in your GraphQL schema to ensure consistency and simplify maintenance.
Graphqlyoga Consolidate duplicated types and fields in your GraphQL Yoga schema to ensure consistency and simplify maintenance.
Hypergraphql Consolidate duplicated objects in HyperGraphQL schemas to streamline API management and reduce complexity.
Jaal Refactor the schema to eliminate duplicated objects by consolidating them into reusable components or types, ensuring consistency and simplifying maintenance.
Juniper Refactor duplicated objects in Juniper framework schemas to ensure consistency and simplify API management.
Lacinia Consolidate duplicated types in Lacinia schemas to ensure consistency and simplify API management.
Lighthouse Optimize image sizes and formats for faster loading times in the Lighthouse framework.
Mercurius Consolidate duplicated objects in Mercurius schemas to streamline API management and reduce complexity.
Morpheusgraphql Consolidate duplicated objects in MorpheusGraphQL schemas to streamline API management and reduce complexity.
Qglgen Consolidate duplicated types in gqlgen schema to ensure consistency and simplify maintenance.
Sangria Refactor the schema to eliminate duplicated types and fields, ensuring each object is defined once and reused where necessary in the Sangria GraphQL framework.
Shopify Consolidate duplicated objects in Shopify's Liquid templates to streamline code management and improve performance.
Stepzen Consolidate duplicated objects in StepZen schemas to streamline API management and reduce complexity.
Strawberry Consolidate duplicated objects in the Strawberry framework by defining reusable types and fragments to simplify schema management and ensure consistency.
Tartiflette Refactor the schema to eliminate duplicated types and fields, ensuring each object is defined once and reused where necessary in the Tartiflette framework.
Wpgraphql Consolidate duplicated types and fields in the WPGraphQL schema to ensure consistency and simplify API management.

REST Specific

Asp_net In the ASP.NET framework, to address the issue of duplicated objects, refactor your codebase to implement the 'Don't Repeat Yourself' (DRY) principle. Consolidate duplicate classes, methods, or schemas into single, reusable components. Utilize inheritance, interfaces, or shared libraries to abstract common functionality. Regularly review your code for redundancies and apply migrations or updates to ensure a single source of truth for each object definition. This will simplify maintenance, reduce errors, and improve the overall performance and scalability of your application.
Ruby_on_rails In Ruby on Rails, to address the issue of duplicated objects in your OpenAPI or GraphQL schemas, refactor your codebase to utilize shared definitions or components. Employ modules or concerns to encapsulate common functionality and types, and use inheritance or mixins to avoid duplication. Ensure that your API documentation is updated accordingly to reflect these changes for clarity and ease of use.
Next_js Consolidate duplicated components and utilize module imports to maintain a single source of truth, enhancing maintainability and reducing complexity in your Next.js application.
Laravel In Laravel, to avoid duplication in your Eloquent models or database migrations, utilize traits for common methods and relationships, and leverage database seeders and factories for consistent data creation. Regularly refactor your code to ensure DRY (Don't Repeat Yourself) principles are followed.
Express_js In Express.js, avoid defining duplicate middleware or route handlers that can cause conflicts or unexpected behavior. Refactor your code to create reusable functions or modules, and ensure that each endpoint is handled by a unique function. Regularly review your routes and middleware for any redundancy and consolidate them when possible to maintain a clean and efficient codebase.
Django In Django, ensure that your models, serializers, and views are designed with the DRY (Don't Repeat Yourself) principle in mind. Refactor any duplicated code by creating abstract base classes, mixins, or utility functions that can be shared across different parts of your application. Regularly review your codebase for redundancies and consolidate any duplicate logic or schema definitions to maintain a clean and efficient codebase.
Symfony In Symfony, to avoid duplication in your API schemas, utilize inheritance and composition with the Serializer component or leverage the PHP8 Attributes in combination with the Symfony Serializer to define reusable schema components. Employ services and dependency injection to share common logic across your application.
Spring_boot In Spring Boot, to address the issue of duplicated objects in OpenAPI or GraphQL schemas, refactor the codebase to create shared DTOs (Data Transfer Objects) or entities that can be reused across different API endpoints. Utilize inheritance or composition to handle common properties and reduce redundancy. Ensure that all references to these objects are updated to point to the shared definitions. Additionally, consider using libraries like ModelMapper to simplify object mapping and maintain consistency. Regularly review your schema to identify potential duplications as part of your API governance process.
Flask In Flask, to avoid duplication in your API schema, utilize inheritance with Python classes or leverage Flask extensions like Flask-RESTPlus or Flask-RESTful. These tools encourage code reuse and help define resources in a clean, DRY (Don't Repeat Yourself) manner. Regularly refactor your code to abstract common functionality and use decorators for shared behavior across endpoints.
Nuxt In Nuxt.js, ensure that components, plugins, and store modules are named and structured uniquely to prevent duplication. Refactor any existing duplicated code by creating reusable components or mixins, and utilize Vuex for shared state management to maintain a single source of truth.
Fastapi In FastAPI, ensure that your schema definitions are centralized and reused rather than duplicated. Utilize Pydantic models to define data structures once and reference them across your endpoints. This approach will help maintain consistency, reduce errors, and simplify updates to your API structure.
Frappe Refactor duplicated code into reusable components
Genzio Refactor duplicated objects in the Genzio framework engine to ensure consistency and simplify maintenance.
Gin Ensure unique route definitions to prevent duplicated handlers in the Gin framework.
Gorilla Consolidate duplicated objects in Gorilla framework schemas to simplify API management and reduce complexity.
Hapi Ensure unique route paths and handler names to avoid conflicts in the Hapi framework.
Hono Consolidate duplicated objects in OpenAPI or GraphQL schemas to streamline API management and reduce complexity.
Jersey Ensure proper resource management by closing Jersey client instances after use to prevent resource leaks.
Koa Use middleware for error handling
Ktor Ensure proper exception handling in Ktor applications to prevent unexpected crashes and improve application stability.
Leptos Refactor duplicated components in Leptos framework to ensure modularity and maintainability.
Macaron Ensure proper session management to prevent session fixation and hijacking in the Macaron framework.
Phoenix Refactor duplicated code into reusable modules or functions to enhance maintainability and reduce complexity in Phoenix Framework applications.
Redwoodjs Consolidate and reuse shared types or components in RedwoodJS to avoid duplication and ensure consistency across your application.
Rocket Refactor duplicated code in Rocket framework engine to improve maintainability and reduce complexity.
Sveltekit Ensure unique component names and routes to avoid conflicts and maintain clarity in SvelteKit applications.

Configuration

Identifier: schema/duplicated_object

Examples

Ignore this check

checks:
  schema/duplicated_object:
    skip: true

Score

  • Escape Severity:

Compliance

  • OWASP: API9:2023
  • OWASP LLM: LLM02:2023
  • pci: 6.5.1
  • gdpr: Article-32
  • soc2: CC1
  • psd2: Article-95
  • iso27001: A.12.6
  • nist: SP800-53
  • fedramp: CM-3

Classification

  • CWE: 710

Score

  • CVSS_VECTOR: CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:N