diff --git a/src/library/PostgREST/Response/OpenAPI.hs b/src/library/PostgREST/Response/OpenAPI.hs
index b2548295d..04a1ec21b 100644
--- a/src/library/PostgREST/Response/OpenAPI.hs
+++ b/src/library/PostgREST/Response/OpenAPI.hs
@@ -30,7 +30,7 @@ import PostgREST.Network (escapeHostName)
import PostgREST.Query.OpenApi (TableAccess (..), TablesAccess)
import PostgREST.SchemaCache (SchemaCache (..))
import PostgREST.SchemaCache.Identifiers (FieldName, QualifiedIdentifier (..))
-import PostgREST.SchemaCache.Relationship (Cardinality (..), Junction (..),
+import PostgREST.SchemaCache.Relationship (Cardinality (..),
Relationship (..), RelationshipsMap)
import PostgREST.SchemaCache.Routine (FuncVolatility (..), Routine (..),
RoutineParam (..))
@@ -110,35 +110,13 @@ parseDefault colType colDefault =
makeTableDef :: RelationshipsMap -> (Table, TableAccess) -> (Text, Schema)
makeTableDef rels (t, access) =
(tn, (mempty :: Schema)
- & description .~ tblDescription
+ & description .~ tableDescription t
& type_ ?~ SwaggerObject
& properties .~ fromList (makeProperty t rels <$> cols)
& required .~ fmap colName (filter (not . colNullable) cols))
where
tn = tableName t
cols = accessibleCols t (taSelectCols access)
- tblDescription = case m2mMarkers t rels of
- [] -> tableDescription t
- ms -> Just $ maybe "" (`T.append` "\n\n") (tableDescription t) <> T.intercalate "\n" ms
-
--- | Emits markers for the many-to-many relationships of a table, so that clients
--- can render these relations. The marker includes the target table(embedding key),
--- the junction table and the junction columns referencing source and target.
-m2mMarkers :: Table -> RelationshipsMap -> [Text]
-m2mMarkers tbl rels = mapMaybe m2mMarker searchedRels
- where
- searchedRels = fromMaybe mempty $ HM.lookup (QualifiedIdentifier (tableSchema tbl) (tableName tbl), tableSchema tbl) rels
- m2mMarker Relationship{relForeignTable, relCardinality=M2M junction} =
- Just $ T.intercalate ""
- [ ""
- ]
- m2mMarker _ = Nothing
- junctionSourceCols junction = T.intercalate "," (snd <$> junColsSource junction)
- junctionTargetCols junction = T.intercalate "," (snd <$> junColsTarget junction)
accessibleCols :: Table -> [FieldName] -> [Column]
accessibleCols t cols = filter ((`elem` cols) . colName) (tableColumnsList t)
diff --git a/test/spec/Feature/OpenApi/OpenApiSpec.hs b/test/spec/Feature/OpenApi/OpenApiSpec.hs
index d675045f1..4381bdac1 100644
--- a/test/spec/Feature/OpenApi/OpenApiSpec.hs
+++ b/test/spec/Feature/OpenApi/OpenApiSpec.hs
@@ -361,15 +361,6 @@ spec withConfig = withConfig baseCfg $ describe "OpenAPI" $ do
}
|]
- it "includes m2m relationship markers in the table description" $ do
- r <- simpleBody <$> get "/"
-
- let beingDescription = r ^? key "definitions" . key "being" . key "description"
-
- liftIO $
- beingDescription `shouldBe` Just
- [aesonQQ|""|]
-
it "includes a composite foreign key marker with the full column mapping" $ do
r <- simpleBody <$> get "/"
@@ -400,15 +391,6 @@ spec withConfig = withConfig baseCfg $ describe "OpenAPI" $ do
}
|]
- it "includes composite m2m relationship markers in the table description" $ do
- r <- simpleBody <$> get "/"
-
- let beingDescription = r ^? key "definitions" . key "comp_being" . key "description"
-
- liftIO $
- beingDescription `shouldBe` Just
- [aesonQQ|""|]
-
describe "Foreign table" $
it "includes foreign table properties" $ do
diff --git a/test/spec/fixtures/schema.sql b/test/spec/fixtures/schema.sql
index 2968b07c6..f95bab78a 100644
--- a/test/spec/fixtures/schema.sql
+++ b/test/spec/fixtures/schema.sql
@@ -1275,29 +1275,6 @@ create table test.comp_component_instance (
constraint comp_component_instance_component_fkey foreign key (product_id, component_id) references test.comp_component(product_id, component_id)
);
--- Tables for testing composite m2m relationships in the OpenAPI output
-create table test.comp_being (
- a int not null,
- b int not null,
- primary key(a, b)
-);
-
-create table test.comp_thing (
- x int not null,
- y int not null,
- primary key(x, y)
-);
-
-create table test.comp_being_thing (
- a int not null,
- b int not null,
- x int not null,
- y int not null,
- primary key(a, b, x, y),
- constraint comp_being_thing_being_fkey foreign key (a, b) references test.comp_being(a, b),
- constraint comp_being_thing_thing_fkey foreign key (x, y) references test.comp_thing(x, y)
-);
-
create function test.single_out_param(num int, OUT num_plus_one int) AS $$
select num + 1;
$$ language sql;