Two schemas are referenced with the same name but different content. Renamed Item to Item-2.
See original GitHub issueIf using subdirectories to organize a large number of components and some of these components share the same file basename (but exist in different subdirectories) you get warnings like this:
[6] paths/beta/rating/merchantRates.yaml:59:7 at #/get/parameters/3
Two schemas are referenced with the same name but different content. Renamed fields to fields-5.
This also comes up with models like models/Order/Item.yaml
and models/Shipment/Item.yaml
because both files are named Item
so they are merged in as Item
and Item-2
and so-on.
Example spec
openapi.yaml
openapi: 3.0.3
info:
title: test
paths:
'/api/global/beta/rating/rateGroups':
$ref: 'paths/beta/rating/rateGroups.yaml'
'/api/global/beta/rating/merchantRates':
$ref: 'paths/beta/rating/merchantRates.yaml'
paths/beta/rating/rateGroups.yaml
get:
summary: List all Rate Groups
description: foo
parameters:
- $ref: ../../../components/parameters/rate/group/fields.yaml
paths/beta/rating/merchantRates.yaml
get:
summary: List all Merchant Rates
description: foo
parameters:
- $ref: ../../../components/parameters/merchant/rate/fields.yaml
Expected behavior The refs are valid so ideally there should not be such warnings and ideally it should not require the refs to be declared explicitly in the top level file as a workaround as that is much more tedious than just directly referencing the files where they are needed.
openapi-cli
Version(s)
1.0.0-beta.73
Issue Analytics
- State:
- Created a year ago
- Comments:5 (4 by maintainers)
I like them remaining as references as that keeps the spec concise and agree that the warnings can safely be ignored but then other warnings get masked quickly… Using one parent folder name as a prefix would be a big improvement in my opinion and probably work in 95% of cases. As of now I’ve resorted to naming files like
Order/OrderItem.yaml
instead ofOrder/Item.yaml
to avoid the warnings.We would like to have the revers behavior 😃 Instead of deduplicating models via adding a number automatically I’d like to error out if this is happening. Is there a way to achieve this?
Context: We have our specs distributed in different repos and bundle it into one big public spec. It’s semantically incorrect for us to have different models with the same name. If this happens the names are too generic and should be revised (e.g. in the above example it should be OrderItem and ShippingItem). Having this we could enforces clear domain based naming schemes and fail fast if people introduce naming conflicts.