biocad / openapi3

OpenAPI 3.0 data model
BSD 3-Clause "New" or "Revised" License
39 stars 54 forks source link

invalid schema #73

Open teto opened 1 year ago

teto commented 1 year ago

I tried to leverage some automation on my openapi spec but they all failed because of errors in the schema:

Semantic error at components.schemas.BaselineCheck_'HasCase_PhysicalUnit
Component names can only contain the characters A-Z a-z 0-9 - . _
Semantic error at components.schemas.BaselineDescriptor_'CategoricalDescriptor
Component names can only contain the characters A-Z a-z 0-9 - . _

also I have names like "PlayerPoly_(PointG_Int)" .

I've tried to add some tests and a fix doing:

...
  , datatypeNameModifier = conformDatatypeNameModifier
...

-- | Adhere to spec https://www.rfc-editor.org/rfc/rfc3986#section-3.1 
-- https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md
conformDatatypeNameModifier :: String -> String
conformDatatypeNameModifier = 
  foldl (\acc x -> acc ++ convertChar x) ""  
  where 
    convertChar = \case 
      '(' -> "_parensL_"
      ')' -> "_parensR_"
--      '\'' -> "_squote_"
      other -> [other]

but seems like a better fix would be to do "percent-encoding" . I wonder if that would be allright and in which case how to do that. Looks like we could import a library like https://hackage.haskell.org/package/network-uri-2.6.4.2/docs/Network-URI.html#v:escapeURIString . Before putting up a PR, I wanted to ask if it's fine ?

teto commented 1 year ago

https://github.com/biocad/openapi3/pull/74