Skip to content

Create tapir module #80

@jisantuc

Description

@jisantuc

Improvement

Schema derivation for case classes depends on Schema[T] being available for all the components. Not just that it could be available -- for exotic types it actually has to exist beforehand (see coproduct types). We should provide a tapir module that provides Schema implicits for all the data types in stac4s. Most of it will be derivable.

Some of the derivations will be incorrect though. for instance the automatic derivation thinks that TwoDimBbox is an object:

@ implicit val twoDimBboxSchema = implicitly[Schema[com.azavea.stac4s.TwoDimBbox]] 
twoDimBboxSchema: Schema[TwoDimBbox] = Schema(                                                            
  SProduct(                                                                                               
    SObjectInfo("com.azavea.stac4s.TwoDimBbox", List()),
    List(           
      ("xmin", Schema(SNumber, false, None, Some("double"), false)),
      ("ymin", Schema(SNumber, false, None, Some("double"), false)),
      ("xmax", Schema(SNumber, false, None, Some("double"), false)),
      ("ymax", Schema(SNumber, false, None, Some("double"), false))
    )                                                                                                     
  ),                     
  false,                                                                                                                                                                                                             
  None,                                                                                                                                                                                                              
  None,                                                                                                                                                                                                              
  false                                                                                                                                                                                                              
)                                                                                                                                                                                                                    

And the automatic derivation for StacLink is a null:

@ implicit val stacLinkSchema: Schema[StacLink] = implicitly[Schema[StacLink]
  ]                 
stacLinkSchema: Schema[StacLink] = null

Notes + Context

This is to support downstream not having to create stac4s schemas in different places, since Schema[T] + Codec[T] in the json lib is normally sufficient for Codec[T] in tapir

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions