Projet

Général

Profil

0001-toulouse_axel-complete-JSONSchemaFromXMLSchema-for-F.patch

Lauréline Guérin, 06 décembre 2019 13:25

Télécharger (2,72 ko)

Voir les différences:

Subject: [PATCH 1/2] toulouse_axel: complete JSONSchemaFromXMLSchema for FILE
 (#38230)

 passerelle/utils/xml.py | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)
passerelle/utils/xml.py
116 116
        xmlschema.qnames.XSD_STRING: 'string',
117 117
        xmlschema.qnames.XSD_INTEGER: 'integer',
118 118
        xmlschema.qnames.XSD_INT: 'integer',
119
        xmlschema.qnames.XSD_POSITIVE_INTEGER: 'integer',
119 120
        xmlschema.qnames.XSD_UNSIGNED_INT: 'integer',
120 121
        xmlschema.qnames.XSD_BOOLEAN: 'boolean',
121 122
        xmlschema.qnames.XSD_DOUBLE: 'number',
......
201 202
        assert isinstance(attributegroup, xmlschema.validators.XsdAttributeGroup)
202 203

  
203 204
        properties = schema.setdefault('properties', OrderedDict())
204
        for component in attributegroup.iter_component():
205
        for component in attributegroup.values():
205 206
            if component.use == 'prohibited':
206 207
                continue
207 208
            if required is not None and component.use != 'optional':
208 209
                if component.name not in schema.get('required', []):
209 210
                    schema.setdefault('required', []).append(component.name)
210
            if component.ref:
211
                raise NotImplementedError(component)
212
            else:
213
                properties[component.name] = cls.simpletype_to_jsonschema(component.type)
211
            properties[component.name] = cls.simpletype_to_jsonschema(component.type)
214 212

  
215 213
    @classmethod
216 214
    def group_to_alternatives(cls, group, alternatives=None):
......
261 259

  
262 260
        alternatives = cls.group_to_alternatives(group)
263 261

  
264
        assert len(alternatives) >= 1 and all(len(alternative) >= 1 for alternative in alternatives), alternatives
265

  
266 262
        def fill_schema_with_alternative(schema, alternative):
267 263
            for component in alternative:
268 264
                properties = schema.setdefault('properties', OrderedDict())
......
309 305
            schema = OrderedDict({'type': 'object'})
310 306
            schema['additionalProperties'] = False
311 307
            if xmltype.attributes:
312
                cls.attributegroup_to_jsonschema(schema)
308
                cls.attributegroup_to_jsonschema(xmltype.attributes, schema)
313 309
            cls.group_to_jsonschema(xmltype.content_type, schema)
314 310
            return schema
315 311

  
316
-