git.iko.soy/typeable/openapi3
on master help sign in
Change warning for inline* helpers to a more correct
658ad6cNickolay Kudasov
src/Data/Swagger/Internal/Schema.hs+6−3
@@ -170,7 +170,8 @@ declareSchemaRef proxy = do
170-- /NOTE:/ if a referenced schema is not found in definitions the predicate is ignored
170-- /NOTE:/ if a referenced schema is not found in definitions the predicate is ignored
171-- and schema stays referenced.
171-- and schema stays referenced.
172--
172--
173+-- __WARNING:__ @'inlineSchemasWhen'@ will produce infinite schemas
173−-- __WARNING:__ @'inlineSchemasWhen'@ will loop when inlining recursive schemas.
174+-- when inlining recursive schemas.
174inlineSchemasWhen :: Data s => (T.Text -> Bool) -> Definitions -> s -> s
175inlineSchemasWhen :: Data s => (T.Text -> Bool) -> Definitions -> s -> s
175inlineSchemasWhen p defs = template %~ deref
176inlineSchemasWhen p defs = template %~ deref
176 where
177 where
@@ -186,14 +187,16 @@ inlineSchemasWhen p defs = template %~ deref
186-- /NOTE:/ if a referenced schema is not found in definitions
187-- /NOTE:/ if a referenced schema is not found in definitions
187-- it stays referenced even if it appears in the list of names.
188-- it stays referenced even if it appears in the list of names.
188--
189--
190+-- __WARNING:__ @'inlineSchemasWhen'@ will produce infinite schemas
189−-- __WARNING:__ @'inlineSchemas'@ will loop when inlining recursive schemas.
191+-- when inlining recursive schemas.
190inlineSchemas :: Data s => [T.Text] -> Definitions -> s -> s
192inlineSchemas :: Data s => [T.Text] -> Definitions -> s -> s
191inlineSchemas names = inlineSchemasWhen (`elem` names)
193inlineSchemas names = inlineSchemasWhen (`elem` names)
192
194
193-- | Inline all schema references for which the definition
195-- | Inline all schema references for which the definition
194-- can be found in @'Definitions'@.
196-- can be found in @'Definitions'@.
195--
197--
198+-- __WARNING:__ @'inlineSchemasWhen'@ will produce infinite schemas
196−-- __WARNING:__ @'inlineAllSchemas'@ will loop when inlining recursive schemas.
199+-- when inlining recursive schemas.
197inlineAllSchemas :: Data s => Definitions -> s -> s
200inlineAllSchemas :: Data s => Definitions -> s -> s
198inlineAllSchemas = inlineSchemasWhen (const True)
201inlineAllSchemas = inlineSchemasWhen (const True)
199
202