Remove version from DFC API URL in specs

We were aiming to use stable URLs to identify resources but the URL
helpers were still using dfc-v1.7 because that was the last and
overriding path of the mounted DFC Provider engine.
This commit is contained in:
Maikel Linke
2023-09-05 14:54:19 +10:00
parent 7654d37fc3
commit df3fc83c8e
11 changed files with 54 additions and 54 deletions

View File

@@ -6,13 +6,13 @@ Openfoodnetwork::Application.routes.draw do
# Mount DFC API endpoints
#
# Latest implemented version:
mount DfcProvider::Engine, at: '/dfc/'
# The DFC prototype is still pointing to the old URL though:
mount DfcProvider::Engine, at: '/dfc-v1.6/', as: :legacy_dfc_provider_engine
mount DfcProvider::Engine, at: '/dfc-v1.7/', as: :v1_7_dfc_provider_engine
# Latest implemented version:
mount DfcProvider::Engine, at: '/dfc/'
namespace :v0 do
resources :products do
collection do

View File

@@ -9,7 +9,7 @@ describe "Addresses", type: :request, swagger_doc: "dfc.yaml", rswag_autodoc: tr
before { login_as user }
path "/api/dfc-v1.7/addresses/{id}" do
path "/api/dfc/addresses/{id}" do
get "Show address" do
parameter name: :id, in: :path, type: :string
produces "application/json"
@@ -20,7 +20,7 @@ describe "Addresses", type: :request, swagger_doc: "dfc.yaml", rswag_autodoc: tr
before { create(:enterprise, owner: user, address:) }
run_test! do
expect(result["@id"]).to eq "http://test.host/api/dfc-v1.7/addresses/40000"
expect(result["@id"]).to eq "http://test.host/api/dfc/addresses/40000"
expect(result["@type"]).to eq "dfc-b:Address"
end
end

View File

@@ -23,7 +23,7 @@ describe "CatalogItems", type: :request, swagger_doc: "dfc.yaml",
before { login_as user }
path "/api/dfc-v1.7/enterprises/{enterprise_id}/catalog_items" do
path "/api/dfc/enterprises/{enterprise_id}/catalog_items" do
parameter name: :enterprise_id, in: :path, type: :string
get "List CatalogItems" do
@@ -77,7 +77,7 @@ describe "CatalogItems", type: :request, swagger_doc: "dfc.yaml",
end
end
path "/api/dfc-v1.7/enterprises/{enterprise_id}/catalog_items/{id}" do
path "/api/dfc/enterprises/{enterprise_id}/catalog_items/{id}" do
parameter name: :enterprise_id, in: :path, type: :string
parameter name: :id, in: :path, type: :string

View File

@@ -23,7 +23,7 @@ describe "Enterprises", type: :request, swagger_doc: "dfc.yaml", rswag_autodoc:
before { login_as user }
path "/api/dfc-v1.7/enterprises/{id}" do
path "/api/dfc/enterprises/{id}" do
get "Show enterprise" do
parameter name: :id, in: :path, type: :string
produces "application/json"

View File

@@ -8,7 +8,7 @@ describe "Persons", type: :request, swagger_doc: "dfc.yaml", rswag_autodoc: true
before { login_as user }
path "/api/dfc-v1.7/persons/{id}" do
path "/api/dfc/persons/{id}" do
get "Show person" do
parameter name: :id, in: :path, type: :string
produces "application/json"

View File

@@ -17,7 +17,7 @@ describe "SuppliedProducts", type: :request, swagger_doc: "dfc.yaml",
before { login_as user }
path "/api/dfc-v1.7/enterprises/{enterprise_id}/supplied_products" do
path "/api/dfc/enterprises/{enterprise_id}/supplied_products" do
parameter name: :enterprise_id, in: :path, type: :string
let(:enterprise_id) { enterprise.id }
@@ -36,7 +36,7 @@ describe "SuppliedProducts", type: :request, swagger_doc: "dfc.yaml",
'@type': "@id"
},
},
'@id': "http://test.host/api/dfc-v1.7/enterprises/6201/supplied_products/0",
'@id': "http://test.host/api/dfc/enterprises/6201/supplied_products/0",
'@type': "dfc-b:SuppliedProduct",
'dfc-b:name': "Apple",
'dfc-b:description': "A delicious heritage apple",
@@ -84,7 +84,7 @@ describe "SuppliedProducts", type: :request, swagger_doc: "dfc.yaml",
dfc_id = json_response["@id"]
expect(dfc_id).to match(
%r|^http://test\.host/api/dfc-v1\.7/enterprises/10000/supplied_products/[0-9]+$|
%r|^http://test\.host/api/dfc/enterprises/10000/supplied_products/[0-9]+$|
)
variant_id = dfc_id.split("/").last.to_i
@@ -102,7 +102,7 @@ describe "SuppliedProducts", type: :request, swagger_doc: "dfc.yaml",
end
end
path "/api/dfc-v1.7/enterprises/{enterprise_id}/supplied_products/{id}" do
path "/api/dfc/enterprises/{enterprise_id}/supplied_products/{id}" do
parameter name: :enterprise_id, in: :path, type: :string
parameter name: :id, in: :path, type: :string

View File

@@ -14,7 +14,7 @@ describe AddressBuilder do
describe ".address" do
it "assigns a semantic id" do
expect(result.semanticId).to eq(
"http://test.host/api/dfc-v1.7/addresses/1"
"http://test.host/api/dfc/addresses/1"
)
end

View File

@@ -13,7 +13,7 @@ describe DfcBuilder do
item = DfcBuilder.catalog_item(variant)
expect(item.semanticId).to eq(
"http://test.host/api/dfc-v1.7/enterprises/7/catalog_items/5"
"http://test.host/api/dfc/enterprises/7/catalog_items/5"
)
end
@@ -24,7 +24,7 @@ describe DfcBuilder do
item = DfcBuilder.catalog_item(variant)
expect(item.product.semanticId).to eq(
"http://test.host/api/dfc-v1.7/enterprises/7/supplied_products/5"
"http://test.host/api/dfc/enterprises/7/supplied_products/5"
)
end
end

View File

@@ -21,7 +21,7 @@ describe EnterpriseBuilder do
it "assigns a semantic id" do
expect(result.semanticId).to eq(
"http://test.host/api/dfc-v1.7/enterprises/10000"
"http://test.host/api/dfc/enterprises/10000"
)
end

View File

@@ -13,7 +13,7 @@ describe SuppliedProductBuilder do
product = builder.supplied_product(variant)
expect(product.semanticId).to eq(
"http://test.host/api/dfc-v1.7/enterprises/7/supplied_products/5"
"http://test.host/api/dfc/enterprises/7/supplied_products/5"
)
end

View File

@@ -38,7 +38,7 @@ security:
- ofn_api_token: []
- ofn_session: []
paths:
"/api/dfc-v1.7/addresses/{id}":
"/api/dfc/addresses/{id}":
get:
summary: Show address
parameters:
@@ -58,7 +58,7 @@ paths:
test_example:
value:
"@context": https://www.datafoodconsortium.org
"@id": http://test.host/api/dfc-v1.7/addresses/40000
"@id": http://test.host/api/dfc/addresses/40000
"@type": dfc-b:Address
dfc-b:hasStreet: 10 Lovely Street
dfc-b:hasPostalCode: '20170'
@@ -66,7 +66,7 @@ paths:
dfc-b:hasCountry: Australia
'404':
description: not found
"/api/dfc-v1.7/enterprises/{enterprise_id}/catalog_items":
"/api/dfc/enterprises/{enterprise_id}/catalog_items":
parameters:
- name: enterprise_id
in: path
@@ -89,23 +89,23 @@ paths:
value:
"@context": https://www.datafoodconsortium.org
"@graph":
- "@id": http://test.host/api/dfc-v1.7/persons/12345
- "@id": http://test.host/api/dfc/persons/12345
"@type": dfc-b:Person
dfc-b:affiliates: http://test.host/api/dfc-v1.7/enterprises/10000
- "@id": http://test.host/api/dfc-v1.7/enterprises/10000
dfc-b:affiliates: http://test.host/api/dfc/enterprises/10000
- "@id": http://test.host/api/dfc/enterprises/10000
"@type": dfc-b:Enterprise
dfc-b:hasAddress: http://test.host/api/dfc-v1.7/addresses/40000
dfc-b:hasAddress: http://test.host/api/dfc/addresses/40000
dfc-b:hasName: Fred's Farm
dfc-b:hasDescription: Beautiful
dfc-b:supplies: http://test.host/api/dfc-v1.7/enterprises/10000/supplied_products/10001
dfc-b:manages: http://test.host/api/dfc-v1.7/enterprises/10000/catalog_items/10001
- "@id": http://test.host/api/dfc-v1.7/enterprises/10000/catalog_items/10001
dfc-b:supplies: http://test.host/api/dfc/enterprises/10000/supplied_products/10001
dfc-b:manages: http://test.host/api/dfc/enterprises/10000/catalog_items/10001
- "@id": http://test.host/api/dfc/enterprises/10000/catalog_items/10001
"@type": dfc-b:CatalogItem
dfc-b:references: http://test.host/api/dfc-v1.7/enterprises/10000/supplied_products/10001
dfc-b:references: http://test.host/api/dfc/enterprises/10000/supplied_products/10001
dfc-b:sku: AR
dfc-b:stockLimitation: 0
dfc-b:offeredThrough: http://test.host/api/dfc-v1.7/enterprises/10000/offers/10001
- "@id": http://test.host/api/dfc-v1.7/enterprises/10000/supplied_products/10001
dfc-b:offeredThrough: http://test.host/api/dfc/enterprises/10000/offers/10001
- "@id": http://test.host/api/dfc/enterprises/10000/supplied_products/10001
"@type": dfc-b:SuppliedProduct
dfc-b:name: Apple
dfc-b:description: Red
@@ -118,13 +118,13 @@ paths:
dfc-b:lifetime: ''
dfc-b:usageOrStorageCondition: ''
dfc-b:totalTheoreticalStock: 0.0
- "@id": http://test.host/api/dfc-v1.7/enterprises/10000/offers/10001
- "@id": http://test.host/api/dfc/enterprises/10000/offers/10001
"@type": dfc-b:Offer
dfc-b:price: 19.99
dfc-b:stockLimitation: 0
'401':
description: unauthorized
"/api/dfc-v1.7/enterprises/{enterprise_id}/catalog_items/{id}":
"/api/dfc/enterprises/{enterprise_id}/catalog_items/{id}":
parameters:
- name: enterprise_id
in: path
@@ -150,13 +150,13 @@ paths:
value:
"@context": https://www.datafoodconsortium.org
"@graph":
- "@id": http://test.host/api/dfc-v1.7/enterprises/10000/catalog_items/10001
- "@id": http://test.host/api/dfc/enterprises/10000/catalog_items/10001
"@type": dfc-b:CatalogItem
dfc-b:references: http://test.host/api/dfc-v1.7/enterprises/10000/supplied_products/10001
dfc-b:references: http://test.host/api/dfc/enterprises/10000/supplied_products/10001
dfc-b:sku: AR
dfc-b:stockLimitation: 0
dfc-b:offeredThrough: http://test.host/api/dfc-v1.7/enterprises/10000/offers/10001
- "@id": http://test.host/api/dfc-v1.7/enterprises/10000/offers/10001
dfc-b:offeredThrough: http://test.host/api/dfc/enterprises/10000/offers/10001
- "@id": http://test.host/api/dfc/enterprises/10000/offers/10001
"@type": dfc-b:Offer
dfc-b:price: 19.99
dfc-b:stockLimitation: 0
@@ -234,7 +234,7 @@ paths:
"@type": "@id"
dfc-b:stockLimitation: '3'
dfc-b:sku: new-sku
"/api/dfc-v1.7/enterprises/{id}":
"/api/dfc/enterprises/{id}":
get:
summary: Show enterprise
parameters:
@@ -255,21 +255,21 @@ paths:
value:
"@context": https://www.datafoodconsortium.org
"@graph":
- "@id": http://test.host/api/dfc-v1.7/enterprises/10000
- "@id": http://test.host/api/dfc/enterprises/10000
"@type": dfc-b:Enterprise
dfc-b:hasAddress: http://test.host/api/dfc-v1.7/addresses/40000
dfc-b:hasAddress: http://test.host/api/dfc/addresses/40000
dfc-b:hasName: Fred's Farm
dfc-b:hasDescription: This is an awesome enterprise
dfc-b:VATnumber: 123 456
dfc-b:supplies: http://test.host/api/dfc-v1.7/enterprises/10000/supplied_products/10001
dfc-b:manages: http://test.host/api/dfc-v1.7/enterprises/10000/catalog_items/10001
- "@id": http://test.host/api/dfc-v1.7/addresses/40000
dfc-b:supplies: http://test.host/api/dfc/enterprises/10000/supplied_products/10001
dfc-b:manages: http://test.host/api/dfc/enterprises/10000/catalog_items/10001
- "@id": http://test.host/api/dfc/addresses/40000
"@type": dfc-b:Address
dfc-b:hasStreet: 42 Doveton Street
dfc-b:hasPostalCode: '20170'
dfc-b:hasCity: Herndon
dfc-b:hasCountry: Australia
- "@id": http://test.host/api/dfc-v1.7/enterprises/10000/supplied_products/10001
- "@id": http://test.host/api/dfc/enterprises/10000/supplied_products/10001
"@type": dfc-b:SuppliedProduct
dfc-b:name: Apple
dfc-b:description: Round
@@ -282,15 +282,15 @@ paths:
dfc-b:lifetime: ''
dfc-b:usageOrStorageCondition: ''
dfc-b:totalTheoreticalStock: 0.0
- "@id": http://test.host/api/dfc-v1.7/enterprises/10000/catalog_items/10001
- "@id": http://test.host/api/dfc/enterprises/10000/catalog_items/10001
"@type": dfc-b:CatalogItem
dfc-b:references: http://test.host/api/dfc-v1.7/enterprises/10000/supplied_products/10001
dfc-b:references: http://test.host/api/dfc/enterprises/10000/supplied_products/10001
dfc-b:sku: APP
dfc-b:stockLimitation: 0
dfc-b:offeredThrough: http://test.host/api/dfc-v1.7/enterprises/10000/offers/10001
dfc-b:offeredThrough: http://test.host/api/dfc/enterprises/10000/offers/10001
'404':
description: not found
"/api/dfc-v1.7/persons/{id}":
"/api/dfc/persons/{id}":
get:
summary: Show person
parameters:
@@ -310,11 +310,11 @@ paths:
test_example:
value:
"@context": https://www.datafoodconsortium.org
"@id": http://test.host/api/dfc-v1.7/persons/10000
"@id": http://test.host/api/dfc/persons/10000
"@type": dfc-b:Person
'404':
description: not found
"/api/dfc-v1.7/enterprises/{enterprise_id}/supplied_products":
"/api/dfc/enterprises/{enterprise_id}/supplied_products":
parameters:
- name: enterprise_id
in: path
@@ -337,7 +337,7 @@ paths:
test_example:
value:
"@context": https://www.datafoodconsortium.org
"@id": http://test.host/api/dfc-v1.7/enterprises/10000/supplied_products/10001
"@id": http://test.host/api/dfc/enterprises/10000/supplied_products/10001
"@type": dfc-b:SuppliedProduct
dfc-b:name: Apple
dfc-b:description: A delicious heritage apple
@@ -361,7 +361,7 @@ paths:
dfc-pt: http://static.datafoodconsortium.org/data/productTypes.rdf#
dfc-b:hasUnit:
"@type": "@id"
"@id": http://test.host/api/dfc-v1.7/enterprises/6201/supplied_products/0
"@id": http://test.host/api/dfc/enterprises/6201/supplied_products/0
"@type": dfc-b:SuppliedProduct
dfc-b:name: Apple
dfc-b:description: A delicious heritage apple
@@ -374,7 +374,7 @@ paths:
dfc-b:lifetime: ''
dfc-b:usageOrStorageCondition: ''
dfc-b:totalTheoreticalStock: 0.0
"/api/dfc-v1.7/enterprises/{enterprise_id}/supplied_products/{id}":
"/api/dfc/enterprises/{enterprise_id}/supplied_products/{id}":
parameters:
- name: enterprise_id
in: path
@@ -399,7 +399,7 @@ paths:
test_example:
value:
"@context": https://www.datafoodconsortium.org
"@id": http://test.host/api/dfc-v1.7/enterprises/10000/supplied_products/10001
"@id": http://test.host/api/dfc/enterprises/10000/supplied_products/10001
"@type": dfc-b:SuppliedProduct
dfc-b:name: Pesto
dfc-b:description: Basil Pesto