Script to generate AJV compatible JSON Schema typescript object modules from an OpenAPI 3 schema. #2315
                  
                    
                      waynesbrain
                    
                  
                
                  started this conversation in
                Show and tell
              
            Replies: 0 comments
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
        
    
Uh oh!
There was an error while loading. Please reload this page.
-
I was searching for a way to re-use my OpenAPI component schemas for validating forms with react-hook-form and AJV.
I found nothing so I created this script - https://gist.github.com/waynesbrain/6f8b423b865efe67b1deb46023a83d94
Disclaimer: This is not the greatest script, I haven't tested it with recursive $refs or with very complex OpenAPI schemas. It was partly written by Claude 3.7 Sonnet.
It converts OpenAPI PUT/POST requestBody schemas to JSON Schemas with referenced definitions, ready for use with AJV, something like this:
Beta Was this translation helpful? Give feedback.
All reactions