Skip to content

Introduce XSD to JSON Schema generator #378

Merged
chathuranga-jayanath-99 merged 9 commits intowso2:mi-ext-v2-ls-alphafrom
chathuranga-jayanath-99:xsd-2-json-without-defs
Mar 25, 2025
Merged

Introduce XSD to JSON Schema generator #378
chathuranga-jayanath-99 merged 9 commits intowso2:mi-ext-v2-ls-alphafrom
chathuranga-jayanath-99:xsd-2-json-without-defs

Conversation

@chathuranga-jayanath-99
Copy link
Copy Markdown
Contributor

@chathuranga-jayanath-99 chathuranga-jayanath-99 commented Mar 17, 2025

Purpose

This PR introduces support for the data mapper to handle input and output from an XSD schema. To enable this functionality, it includes the necessary changes to generate a corresponding JSON schema from the XSD schema.

This update introduces support for handling both Complex and Simple types in the XSD schema through specialized processors: ComplexTypeProcessor and SimpleTypeProcessor.

Complex Type Example

<xs:complexType name="PersonType">
    <xs:sequence>
        <xs:element name="FirstName" type="xs:string"/>
        <xs:element name="LastName" type="xs:string"/>
        <xs:element name="Age" type="xs:int"/>
    </xs:sequence>
</xs:complexType>

Simple Type Example

<xs:element name="FirstName" type="xs:string"/>

For JSON schema generation, we introduce the JsonSchemaNode class as the parent class, with the following subclasses to handle different schema elements:

  • JsonSchemaArrayNode: Represents an array in the JSON schema.
  • JsonSchemaObjectNode: Represents an object type node in the JSON schema.
  • JsonSchemaElementValueNode: Represents an object type node for elements that accept both values and attributes in the XSD.
  • JsonSchemaOneOfNode: Represents an object with oneOf field containing multiple schema objects .

These changes provide a structure for processing and generating both XSD and JSON schema representations.

@chathuranga-jayanath-99 chathuranga-jayanath-99 merged commit fd120db into wso2:mi-ext-v2-ls-alpha Mar 25, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants