Create AsyncAPI/OpenAPI schema parser
Create AsyncAPI/OpenAPI schema to JSON Schema Draft 07 converter. It should have a single method as follows:
.Parse(schema []byte) (result json.RawMessage, error)
result must be a JSON Schema Draft 07-compatible of type json.RawMessage.
Implementation suggestion
We could create this library separated from the parser so other projects can benefit from it too.
Differences between OpenAPI/AsyncAPI schemas and JSON Schema Draft 07 schemas
nullable: Must translate to type array, e.g.,"type": ["string", null]discriminator: Must be removed or ignored, i.e., it must not be included in the JSON Schema Draft 07 schema. There's not strong opinion here, so if you prefer to just keep it, it would be just fine too.xml: Should remain the same as in OpenAPI schema.externalDocs: Should remain the same as in OpenAPI schema.example: Should be renamed toexamplesand be of type array.deprecated: Should remain the same as in OpenAPI schema.readOnly: Should remain the same as in OpenAPI schema.writeOnly: Should remain the same as in OpenAPI schema.
References
- https://github.com/mikunn/openapi-schema-to-json-schema
- [ ] :bug: Unit tests
- [ ] :books: Documentation
I'd like to work on this if possible.
Absolutely! Just want to remark that this is just for schemas, not the whole OpenAPI/AsyncAPI document.
@fmvilas Great :D ! Alright, I'll have a look at the repo you linked this weekend. If I have any questions I'll let you know. Also, could you assign the issue to me?
Done!
@fmvilas I've read the documentation in the repository you linked. Am I right in concluding the aim is to parse an AsyncAPI-spec and convert it to a JSON-schema so other software can use the JSON-schema to validate incoming/outgoing messages?
You're totally right :)
This way we can leverage existing JSON Schema tooling, which is a lot.
@fmvilas I might take a bit longer to get this fixed. I'm on developing on Windows and I'm encountering some issues when compiling the code-base to C. I'm currently looking for a solution that doesn't involve to much hassle.
I'd forget about the parser and would do it as a separate library/repo. You don't need the rest of the parser nor compiling it to C to make it work.
Make it simpler and go for a simple Go library that takes a byte array and returns a json.RawMessage and error:
func Parse(protobufSchema []byte) (json.RawMessage, error) {
...
}
See more here: https://github.com/asyncapi/parser/blob/master/TECHNICAL%20PROPOSAL.md#api-of-a-specific-schema-parser-instance-eg-protobuf-schema-parser
This issue has been automatically marked as stale because it has not had recent activity :sleeping: It will be closed in 30 days if no further activity occurs. To unstale this issue, add a comment with detailed explanation. Thank you for your contributions :heart: