@api-client/core 0.19.9 → 0.19.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +9 -63
- package/Testing.md +1 -1
- package/bin/test.ts +1 -12
- package/build/src/browser.d.ts +0 -15
- package/build/src/browser.d.ts.map +1 -1
- package/build/src/browser.js +0 -17
- package/build/src/browser.js.map +1 -1
- package/build/src/decorators/observed.d.ts.map +1 -1
- package/build/src/decorators/observed.js +91 -0
- package/build/src/decorators/observed.js.map +1 -1
- package/build/src/events/EventTypes.d.ts +0 -6
- package/build/src/events/EventTypes.d.ts.map +1 -1
- package/build/src/events/EventTypes.js +0 -2
- package/build/src/events/EventTypes.js.map +1 -1
- package/build/src/events/Events.d.ts +0 -2
- package/build/src/events/Events.d.ts.map +1 -1
- package/build/src/events/Events.js +0 -2
- package/build/src/events/Events.js.map +1 -1
- package/build/src/index.d.ts +0 -15
- package/build/src/index.d.ts.map +1 -1
- package/build/src/index.js +0 -17
- package/build/src/index.js.map +1 -1
- package/build/src/modeling/ApiModel.d.ts +21 -7
- package/build/src/modeling/ApiModel.d.ts.map +1 -1
- package/build/src/modeling/ApiModel.js +70 -29
- package/build/src/modeling/ApiModel.js.map +1 -1
- package/build/src/modeling/Bindings.d.ts +3 -3
- package/build/src/modeling/Bindings.d.ts.map +1 -1
- package/build/src/modeling/Bindings.js.map +1 -1
- package/build/src/modeling/DomainAssociation.d.ts +5 -5
- package/build/src/modeling/DomainAssociation.d.ts.map +1 -1
- package/build/src/modeling/DomainAssociation.js.map +1 -1
- package/build/src/modeling/DomainEntity.d.ts +2 -3
- package/build/src/modeling/DomainEntity.d.ts.map +1 -1
- package/build/src/modeling/DomainEntity.js +1 -1
- package/build/src/modeling/DomainEntity.js.map +1 -1
- package/build/src/modeling/DomainProperty.d.ts +2 -3
- package/build/src/modeling/DomainProperty.d.ts.map +1 -1
- package/build/src/modeling/DomainProperty.js +1 -1
- package/build/src/modeling/DomainProperty.js.map +1 -1
- package/build/src/modeling/DomainValidation.d.ts +1 -1
- package/build/src/modeling/DomainValidation.d.ts.map +1 -1
- package/build/src/modeling/DomainValidation.js.map +1 -1
- package/build/src/modeling/ExposedEntity.d.ts +14 -0
- package/build/src/modeling/ExposedEntity.d.ts.map +1 -1
- package/build/src/modeling/ExposedEntity.js +59 -6
- package/build/src/modeling/ExposedEntity.js.map +1 -1
- package/build/src/modeling/actions/Action.d.ts +11 -1
- package/build/src/modeling/actions/Action.d.ts.map +1 -1
- package/build/src/modeling/actions/Action.js +21 -3
- package/build/src/modeling/actions/Action.js.map +1 -1
- package/build/src/modeling/actions/CreateAction.d.ts +2 -1
- package/build/src/modeling/actions/CreateAction.d.ts.map +1 -1
- package/build/src/modeling/actions/CreateAction.js +2 -2
- package/build/src/modeling/actions/CreateAction.js.map +1 -1
- package/build/src/modeling/actions/DeleteAction.d.ts +2 -1
- package/build/src/modeling/actions/DeleteAction.d.ts.map +1 -1
- package/build/src/modeling/actions/DeleteAction.js +2 -2
- package/build/src/modeling/actions/DeleteAction.js.map +1 -1
- package/build/src/modeling/actions/ListAction.d.ts +2 -1
- package/build/src/modeling/actions/ListAction.d.ts.map +1 -1
- package/build/src/modeling/actions/ListAction.js +2 -2
- package/build/src/modeling/actions/ListAction.js.map +1 -1
- package/build/src/modeling/actions/ReadAction.d.ts +2 -1
- package/build/src/modeling/actions/ReadAction.d.ts.map +1 -1
- package/build/src/modeling/actions/ReadAction.js +2 -2
- package/build/src/modeling/actions/ReadAction.js.map +1 -1
- package/build/src/modeling/actions/SearchAction.d.ts +2 -1
- package/build/src/modeling/actions/SearchAction.d.ts.map +1 -1
- package/build/src/modeling/actions/SearchAction.js +2 -2
- package/build/src/modeling/actions/SearchAction.js.map +1 -1
- package/build/src/modeling/actions/UpdateAction.d.ts +2 -1
- package/build/src/modeling/actions/UpdateAction.d.ts.map +1 -1
- package/build/src/modeling/actions/UpdateAction.js +2 -2
- package/build/src/modeling/actions/UpdateAction.js.map +1 -1
- package/build/src/modeling/actions/index.d.ts +2 -1
- package/build/src/modeling/actions/index.d.ts.map +1 -1
- package/build/src/modeling/actions/index.js +7 -7
- package/build/src/modeling/actions/index.js.map +1 -1
- package/build/src/modeling/ai/types.d.ts +2 -2
- package/build/src/modeling/ai/types.d.ts.map +1 -1
- package/build/src/modeling/ai/types.js.map +1 -1
- package/build/src/{amf → modeling/amf}/DataValueGenerator.d.ts +1 -1
- package/build/src/modeling/amf/DataValueGenerator.d.ts.map +1 -0
- package/build/src/{amf → modeling/amf}/DataValueGenerator.js +2 -3
- package/build/src/modeling/amf/DataValueGenerator.js.map +1 -0
- package/build/src/modeling/amf/ShapeGenerator.d.ts +20 -20
- package/build/src/modeling/amf/ShapeGenerator.d.ts.map +1 -1
- package/build/src/modeling/amf/ShapeGenerator.js +16 -18
- package/build/src/modeling/amf/ShapeGenerator.js.map +1 -1
- package/build/src/modeling/amf/core_types.d.ts +9 -0
- package/build/src/modeling/amf/core_types.d.ts.map +1 -0
- package/build/src/modeling/amf/core_types.js +45 -0
- package/build/src/modeling/amf/core_types.js.map +1 -0
- package/build/src/modeling/index.d.ts +1 -0
- package/build/src/modeling/index.d.ts.map +1 -1
- package/build/src/modeling/index.js +1 -0
- package/build/src/modeling/index.js.map +1 -1
- package/build/src/modeling/types.d.ts +67 -0
- package/build/src/modeling/types.d.ts.map +1 -1
- package/build/src/modeling/types.js.map +1 -1
- package/build/src/modeling/validation/api_model_rules.d.ts +15 -0
- package/build/src/modeling/validation/api_model_rules.d.ts.map +1 -0
- package/build/src/modeling/validation/api_model_rules.js +599 -0
- package/build/src/modeling/validation/api_model_rules.js.map +1 -0
- package/build/src/modeling/validation/association_validation.d.ts.map +1 -1
- package/build/src/modeling/validation/association_validation.js +1 -3
- package/build/src/modeling/validation/association_validation.js.map +1 -1
- package/build/src/models/http-flows/LegacyTranslator.js +1 -1
- package/build/src/models/http-flows/LegacyTranslator.js.map +1 -1
- package/build/src/runtime/http-runner/HttpFlows.js +1 -1
- package/build/src/runtime/http-runner/HttpFlows.js.map +1 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/eslint.config.js +0 -2
- package/package.json +27 -135
- package/src/decorators/observed.ts +91 -0
- package/src/events/EventTypes.ts +0 -2
- package/src/events/Events.ts +0 -2
- package/src/modeling/ApiModel.ts +73 -33
- package/src/modeling/Bindings.ts +3 -3
- package/src/modeling/DomainAssociation.ts +5 -5
- package/src/modeling/DomainEntity.ts +3 -4
- package/src/modeling/DomainProperty.ts +3 -4
- package/src/modeling/DomainValidation.ts +1 -1
- package/src/modeling/ExposedEntity.ts +63 -9
- package/src/modeling/actions/Action.ts +25 -2
- package/src/modeling/actions/CreateAction.ts +3 -2
- package/src/modeling/actions/DeleteAction.ts +3 -2
- package/src/modeling/actions/ListAction.ts +3 -2
- package/src/modeling/actions/ReadAction.ts +3 -2
- package/src/modeling/actions/SearchAction.ts +3 -2
- package/src/modeling/actions/UpdateAction.ts +3 -2
- package/src/modeling/ai/types.ts +2 -2
- package/src/{amf → modeling/amf}/DataValueGenerator.ts +3 -4
- package/src/modeling/amf/ShapeGenerator.ts +45 -61
- package/src/modeling/amf/core_types.ts +47 -0
- package/src/modeling/types.ts +70 -0
- package/src/modeling/validation/api_model_rules.ts +640 -0
- package/src/modeling/validation/api_model_validation_rules.md +58 -0
- package/src/modeling/validation/association_validation.ts +1 -3
- package/src/models/http-flows/LegacyTranslator.ts +1 -1
- package/src/runtime/http-runner/HttpFlows.ts +1 -1
- package/tests/unit/modeling/actions/Action.spec.ts +40 -8
- package/tests/unit/modeling/actions/CreateAction.spec.ts +5 -5
- package/tests/unit/modeling/actions/DeleteAction.spec.ts +6 -6
- package/tests/unit/modeling/actions/ListAction.spec.ts +7 -7
- package/tests/unit/modeling/actions/ReadAction.spec.ts +6 -6
- package/tests/unit/modeling/actions/SearchAction.spec.ts +6 -6
- package/tests/unit/modeling/actions/UpdateAction.spec.ts +6 -6
- package/tests/unit/{amf → modeling/amf}/data_value_generator.spec.ts +2 -2
- package/tests/unit/modeling/amf/shape_generator.spec.ts +146 -167
- package/tests/unit/modeling/api_model.spec.ts +190 -13
- package/tests/unit/modeling/api_model_expose_entity.spec.ts +43 -19
- package/tests/unit/modeling/api_model_remove_entity.spec.ts +6 -6
- package/tests/unit/modeling/domain_asociation.spec.ts +13 -13
- package/tests/unit/modeling/exposed_entity.spec.ts +123 -3
- package/tests/unit/modeling/exposed_entity_actions.spec.ts +41 -18
- package/tests/unit/modeling/exposed_entity_setter_validation.spec.ts +1 -1
- package/tests/unit/modeling/rules/restoring_rules.spec.ts +9 -5
- package/tests/unit/modeling/validation/api_model_rules.spec.ts +324 -0
- package/tests/unit/runtime/runners/http_assertion_runner.spec.ts +1 -1
- package/tests/unit/runtime/runners/http_flow_runner.spec.ts +1 -1
- package/tests/unit/runtime/runners/project_runner.spec.ts +1 -1
- package/tests/unit/runtime/runners/request_runner.spec.ts +1 -1
- package/tests/unit/runtime/runners/serial_runner.spec.ts +1 -1
- package/tsconfig.browser.json +1 -1
- package/tsconfig.node.json +1 -1
- package/bin/test-web.ts +0 -6
- package/build/src/amf/AmfMixin.d.ts +0 -396
- package/build/src/amf/AmfMixin.d.ts.map +0 -1
- package/build/src/amf/AmfMixin.js +0 -1138
- package/build/src/amf/AmfMixin.js.map +0 -1
- package/build/src/amf/AmfSerializer.d.ts +0 -137
- package/build/src/amf/AmfSerializer.d.ts.map +0 -1
- package/build/src/amf/AmfSerializer.js +0 -1947
- package/build/src/amf/AmfSerializer.js.map +0 -1
- package/build/src/amf/AmfTypes.d.ts +0 -25
- package/build/src/amf/AmfTypes.d.ts.map +0 -1
- package/build/src/amf/AmfTypes.js +0 -143
- package/build/src/amf/AmfTypes.js.map +0 -1
- package/build/src/amf/ApiExampleGenerator.d.ts +0 -40
- package/build/src/amf/ApiExampleGenerator.d.ts.map +0 -1
- package/build/src/amf/ApiExampleGenerator.js +0 -112
- package/build/src/amf/ApiExampleGenerator.js.map +0 -1
- package/build/src/amf/ApiMonacoSchemaGenerator.d.ts +0 -68
- package/build/src/amf/ApiMonacoSchemaGenerator.d.ts.map +0 -1
- package/build/src/amf/ApiMonacoSchemaGenerator.js +0 -248
- package/build/src/amf/ApiMonacoSchemaGenerator.js.map +0 -1
- package/build/src/amf/ApiSchemaGenerator.d.ts +0 -56
- package/build/src/amf/ApiSchemaGenerator.d.ts.map +0 -1
- package/build/src/amf/ApiSchemaGenerator.js +0 -94
- package/build/src/amf/ApiSchemaGenerator.js.map +0 -1
- package/build/src/amf/ApiSchemaValues.d.ts +0 -111
- package/build/src/amf/ApiSchemaValues.d.ts.map +0 -1
- package/build/src/amf/ApiSchemaValues.js +0 -463
- package/build/src/amf/ApiSchemaValues.js.map +0 -1
- package/build/src/amf/DataValueGenerator.d.ts.map +0 -1
- package/build/src/amf/DataValueGenerator.js.map +0 -1
- package/build/src/amf/Parsing.d.ts +0 -48
- package/build/src/amf/Parsing.d.ts.map +0 -1
- package/build/src/amf/Parsing.js +0 -2
- package/build/src/amf/Parsing.js.map +0 -1
- package/build/src/amf/Utils.d.ts +0 -37
- package/build/src/amf/Utils.d.ts.map +0 -1
- package/build/src/amf/Utils.js +0 -169
- package/build/src/amf/Utils.js.map +0 -1
- package/build/src/amf/data-node/DataNodeBase.d.ts +0 -34
- package/build/src/amf/data-node/DataNodeBase.d.ts.map +0 -1
- package/build/src/amf/data-node/DataNodeBase.js +0 -77
- package/build/src/amf/data-node/DataNodeBase.js.map +0 -1
- package/build/src/amf/data-node/JsonDataNodeGenerator.d.ts +0 -15
- package/build/src/amf/data-node/JsonDataNodeGenerator.d.ts.map +0 -1
- package/build/src/amf/data-node/JsonDataNodeGenerator.js +0 -23
- package/build/src/amf/data-node/JsonDataNodeGenerator.js.map +0 -1
- package/build/src/amf/data-node/UrlEncodedDataNodeGenerator.d.ts +0 -14
- package/build/src/amf/data-node/UrlEncodedDataNodeGenerator.d.ts.map +0 -1
- package/build/src/amf/data-node/UrlEncodedDataNodeGenerator.js +0 -48
- package/build/src/amf/data-node/UrlEncodedDataNodeGenerator.js.map +0 -1
- package/build/src/amf/data-node/XmlDataNodeGenerator.d.ts +0 -22
- package/build/src/amf/data-node/XmlDataNodeGenerator.d.ts.map +0 -1
- package/build/src/amf/data-node/XmlDataNodeGenerator.js +0 -34
- package/build/src/amf/data-node/XmlDataNodeGenerator.js.map +0 -1
- package/build/src/amf/definitions/Amf.d.ts +0 -363
- package/build/src/amf/definitions/Amf.d.ts.map +0 -1
- package/build/src/amf/definitions/Amf.js +0 -3
- package/build/src/amf/definitions/Amf.js.map +0 -1
- package/build/src/amf/definitions/Api.d.ts +0 -383
- package/build/src/amf/definitions/Api.d.ts.map +0 -1
- package/build/src/amf/definitions/Api.js +0 -2
- package/build/src/amf/definitions/Api.js.map +0 -1
- package/build/src/amf/definitions/Base.d.ts +0 -12
- package/build/src/amf/definitions/Base.d.ts.map +0 -1
- package/build/src/amf/definitions/Base.js +0 -2
- package/build/src/amf/definitions/Base.js.map +0 -1
- package/build/src/amf/definitions/Namespace.d.ts +0 -327
- package/build/src/amf/definitions/Namespace.d.ts.map +0 -1
- package/build/src/amf/definitions/Namespace.js +0 -346
- package/build/src/amf/definitions/Namespace.js.map +0 -1
- package/build/src/amf/definitions/Shapes.d.ts +0 -312
- package/build/src/amf/definitions/Shapes.d.ts.map +0 -1
- package/build/src/amf/definitions/Shapes.js +0 -87
- package/build/src/amf/definitions/Shapes.js.map +0 -1
- package/build/src/amf/models/AmfDataNode.d.ts +0 -67
- package/build/src/amf/models/AmfDataNode.d.ts.map +0 -1
- package/build/src/amf/models/AmfDataNode.js +0 -192
- package/build/src/amf/models/AmfDataNode.js.map +0 -1
- package/build/src/amf/shape/ShapeBase.d.ts +0 -74
- package/build/src/amf/shape/ShapeBase.d.ts.map +0 -1
- package/build/src/amf/shape/ShapeBase.js +0 -93
- package/build/src/amf/shape/ShapeBase.js.map +0 -1
- package/build/src/amf/shape/ShapeJsonSchemaGenerator.d.ts +0 -47
- package/build/src/amf/shape/ShapeJsonSchemaGenerator.d.ts.map +0 -1
- package/build/src/amf/shape/ShapeJsonSchemaGenerator.js +0 -420
- package/build/src/amf/shape/ShapeJsonSchemaGenerator.js.map +0 -1
- package/build/src/amf/shape/ShapeXmlSchemaGenerator.d.ts +0 -85
- package/build/src/amf/shape/ShapeXmlSchemaGenerator.d.ts.map +0 -1
- package/build/src/amf/shape/ShapeXmlSchemaGenerator.js +0 -852
- package/build/src/amf/shape/ShapeXmlSchemaGenerator.js.map +0 -1
- package/build/src/events/amf/AmfEventTypes.d.ts +0 -7
- package/build/src/events/amf/AmfEventTypes.d.ts.map +0 -1
- package/build/src/events/amf/AmfEventTypes.js +0 -7
- package/build/src/events/amf/AmfEventTypes.js.map +0 -1
- package/build/src/events/amf/AmfEvents.d.ts +0 -34
- package/build/src/events/amf/AmfEvents.d.ts.map +0 -1
- package/build/src/events/amf/AmfEvents.js +0 -63
- package/build/src/events/amf/AmfEvents.js.map +0 -1
- package/build/src/mocking/RandExp.d.ts +0 -55
- package/build/src/mocking/RandExp.d.ts.map +0 -1
- package/build/src/mocking/RandExp.js +0 -302
- package/build/src/mocking/RandExp.js.map +0 -1
- package/build/src/mocking/lib/ret.d.ts +0 -16
- package/build/src/mocking/lib/ret.d.ts.map +0 -1
- package/build/src/mocking/lib/ret.js +0 -284
- package/build/src/mocking/lib/ret.js.map +0 -1
- package/data/apis/APIC-187/APIC-187.raml +0 -21
- package/data/apis/APIC-187/dataType.raml +0 -132
- package/data/apis/APIC-187/example.raml +0 -84
- package/data/apis/APIC-188/APIC-188.raml +0 -21
- package/data/apis/APIC-188/dataType.raml +0 -132
- package/data/apis/APIC-188/example.raml +0 -84
- package/data/apis/APIC-233/APIC-233.raml +0 -15
- package/data/apis/APIC-391/APIC-391.raml +0 -44
- package/data/apis/APIC-391/examples/post-body-request-example.raml +0 -7
- package/data/apis/APIC-483/APIC-483.raml +0 -16
- package/data/apis/APIC-483/example/list-of-bank-succ.json +0 -32
- package/data/apis/APIC-483/schema/response-retrieve-list-bank.json +0 -68
- package/data/apis/APIC-487/APIC-487.raml +0 -36
- package/data/apis/APIC-655/APIC-655.raml +0 -44
- package/data/apis/APIC-655/delivery.json +0 -12
- package/data/apis/APIC-689/APIC-689.raml +0 -20
- package/data/apis/APIC-690/APIC-690.raml +0 -17
- package/data/apis/APIC-690/datatypes/Address.raml +0 -10
- package/data/apis/APIC-690/datatypes/Customer.raml +0 -17
- package/data/apis/APIC-690/examples/CustomerExample2.raml +0 -17
- package/data/apis/APIC-690/examples/CustomersExample.raml +0 -34
- package/data/apis/SE-10469/Purchase-Order-oagis-id-dd32f9c6c01048a19e15c423c9c741ae.json +0 -1383
- package/data/apis/SE-10469/SE-10469.raml +0 -11
- package/data/apis/SE-13092/Examples/PersonExample.raml +0 -7
- package/data/apis/SE-13092/SE-13092.raml +0 -37
- package/data/apis/SE-13092/datatypes/Address.raml +0 -5
- package/data/apis/SE-13092/datatypes/InlineType.raml +0 -5
- package/data/apis/SE-13092/datatypes/Person.raml +0 -15
- package/data/apis/SE-22063/SE-22063.raml +0 -14
- package/data/apis/SE-22063/stock.raml +0 -41
- package/data/apis/amf-helper-api/amf-helper-api.raml +0 -1024
- package/data/apis/amf-helper-api/examples/comment-example.json +0 -42
- package/data/apis/amf-helper-api/examples/commentCreateRequest-example.json +0 -7
- package/data/apis/amf-helper-api/examples/commentList-example.json +0 -48
- package/data/apis/amf-helper-api/examples/person.json +0 -14
- package/data/apis/amf-helper-api/examples/person.raml +0 -13
- package/data/apis/amf-helper-api/examples/person.xml +0 -14
- package/data/apis/amf-helper-api/libraries/comment-lib.raml +0 -143
- package/data/apis/amf-helper-api/library.raml +0 -7
- package/data/apis/amf-helper-api/schemas/person.json +0 -104
- package/data/apis/amf-helper-api/schemas/person.xsd +0 -26
- package/data/apis/amf-helper-api/traits/file.raml +0 -33
- package/data/apis/amf-helper-api/traits/pagination.raml +0 -80
- package/data/apis/amf-helper-api/traits/results.raml +0 -19
- package/data/apis/amf-helper-api/traits/visibility.raml +0 -14
- package/data/apis/amf-helper-api/types/app-person.raml +0 -101
- package/data/apis/amf-helper-api/types/dimensions.raml +0 -24
- package/data/apis/amf-helper-api/types/external-type.raml +0 -7
- package/data/apis/amf-helper-api/types/image.raml +0 -23
- package/data/apis/amf-helper-api/types/product.raml +0 -52
- package/data/apis/amf-helper-api/types/resource.raml +0 -11
- package/data/apis/amf-helper-api/types/standard-request.raml +0 -50
- package/data/apis/amf-helper-api/types/user.raml +0 -37
- package/data/apis/arc-demo-api/arc-demo-api.raml +0 -468
- package/data/apis/arc-demo-api/examples/e400.xml +0 -4
- package/data/apis/arc-demo-api/examples/e401.xml +0 -4
- package/data/apis/arc-demo-api/examples/e404.xml +0 -4
- package/data/apis/arc-demo-api/examples/image.xml +0 -5
- package/data/apis/arc-demo-api/examples/messages-example.json +0 -22
- package/data/apis/arc-demo-api/examples/messages-sent-example.json +0 -15
- package/data/apis/arc-demo-api/examples/person.json +0 -14
- package/data/apis/arc-demo-api/examples/person.url.encoded +0 -1
- package/data/apis/arc-demo-api/examples/person.xml +0 -14
- package/data/apis/arc-demo-api/examples/product.xml +0 -9
- package/data/apis/arc-demo-api/library.raml +0 -36
- package/data/apis/arc-demo-api/resourceTypes/app-person.raml +0 -49
- package/data/apis/arc-demo-api/resourceTypes/example-types.raml +0 -45
- package/data/apis/arc-demo-api/resourceTypes/image.raml +0 -23
- package/data/apis/arc-demo-api/resourceTypes/message-sent-type.raml +0 -23
- package/data/apis/arc-demo-api/resourceTypes/message-type.raml +0 -33
- package/data/apis/arc-demo-api/resourceTypes/product.raml +0 -52
- package/data/apis/arc-demo-api/resourceTypes/resource.raml +0 -11
- package/data/apis/arc-demo-api/schemas/error-response.xsd +0 -11
- package/data/apis/arc-demo-api/schemas/image.xsd +0 -11
- package/data/apis/arc-demo-api/schemas/person.json +0 -104
- package/data/apis/arc-demo-api/schemas/person.xsd +0 -26
- package/data/apis/arc-demo-api/schemas/product.xsd +0 -17
- package/data/apis/arc-demo-api/securitySchemes/basic.raml +0 -5
- package/data/apis/arc-demo-api/securitySchemes/oauth_2_0.raml +0 -29
- package/data/apis/arc-demo-api/securitySchemes/x-custom.raml +0 -26
- package/data/apis/arc-demo-api/traits/adminable.raml +0 -23
- package/data/apis/arc-demo-api/traits/pagination.raml +0 -83
- package/data/apis/arc-demo-api/traits/rate-limited.raml +0 -9
- package/data/apis/async-api/async-api.yaml +0 -96
- package/data/apis/example-generator-api/contact-email-example.raml +0 -6
- package/data/apis/example-generator-api/contact-example.raml +0 -5
- package/data/apis/example-generator-api/contact-fax-example.raml +0 -5
- package/data/apis/example-generator-api/contact-website-example.raml +0 -2
- package/data/apis/example-generator-api/example-1.raml +0 -6
- package/data/apis/example-generator-api/example-2.raml +0 -9
- package/data/apis/example-generator-api/example-3.raml +0 -4
- package/data/apis/example-generator-api/example-4.raml +0 -2
- package/data/apis/example-generator-api/example-5.raml +0 -4
- package/data/apis/example-generator-api/example-6.raml +0 -2
- package/data/apis/example-generator-api/example-7.raml +0 -5
- package/data/apis/example-generator-api/example-generator-api.raml +0 -423
- package/data/apis/example-generator-api/example.json +0 -14
- package/data/apis/example-generator-api/example.xml +0 -15
- package/data/apis/example-generator-api/example.xsd +0 -26
- package/data/apis/example-generator-api/examples/employee.raml +0 -7
- package/data/apis/example-generator-api/examples/employees.raml +0 -7
- package/data/apis/example-generator-api/linked-named-example.raml +0 -21
- package/data/apis/example-generator-api/named-example-with-link.raml +0 -5
- package/data/apis/example-generator-api/named-example.raml +0 -9
- package/data/apis/example-generator-api/user-json-example.raml +0 -17
- package/data/apis/example-generator-api/user-raml-example.raml +0 -37
- package/data/apis/example-generator-api/user.json +0 -8
- package/data/apis/example-generator-api/user.raml +0 -18
- package/data/apis/example-generator-api/users-json-example.raml +0 -17
- package/data/apis/example-generator-api/users-raml-example.raml +0 -32
- package/data/apis/example-generator-api/users.json +0 -8
- package/data/apis/expanded-api/expanded-api.raml +0 -8
- package/data/apis/flattened-api/flattened-api.raml +0 -8
- package/data/apis/multiple-servers/multiple-servers.yaml +0 -112
- package/data/apis/oas-3-api/oas-3-api.yaml +0 -356
- package/data/apis/oas-date/oas-date.yaml +0 -28
- package/data/apis/oas-types/oas-types.yaml +0 -159
- package/data/apis/oas-unions/oas-unions.yaml +0 -75
- package/data/apis/petstore/petstore.yaml +0 -954
- package/data/apis/raml-date/raml-date.raml +0 -28
- package/data/apis/recursive/recursive.raml +0 -14
- package/data/apis/schema-api/examples/person.json +0 -14
- package/data/apis/schema-api/examples/person.raml +0 -14
- package/data/apis/schema-api/examples/person.url.encoded +0 -1
- package/data/apis/schema-api/examples/person.xml +0 -14
- package/data/apis/schema-api/library/demo-types.raml +0 -43
- package/data/apis/schema-api/schema-api.raml +0 -656
- package/data/apis/schema-api/schemas/person.json +0 -104
- package/data/apis/schema-api/schemas/person.xsd +0 -26
- package/data/apis/schema-api/types/DemoPerson.raml +0 -67
- package/data/apis/secured-api/oauth-2-custom-settings.raml +0 -143
- package/data/apis/secured-api/oauth2-header-delivery.raml +0 -13
- package/data/apis/secured-api/oauth2-no-delivery.raml +0 -8
- package/data/apis/secured-api/oauth2-no-grants.raml +0 -12
- package/data/apis/secured-api/oauth2-pkce.raml +0 -13
- package/data/apis/secured-api/oauth2-query-delivery.raml +0 -13
- package/data/apis/secured-api/oauth_1_0.raml +0 -8
- package/data/apis/secured-api/oauth_1_0_no-settings.raml +0 -3
- package/data/apis/secured-api/oauth_1_0_no-signature.raml +0 -7
- package/data/apis/secured-api/oauth_1_0_signature.raml +0 -8
- package/data/apis/secured-api/passthrough-querystring.raml +0 -16
- package/data/apis/secured-api/passthrough.raml +0 -24
- package/data/apis/secured-api/secured-api.raml +0 -231
- package/data/apis/secured-api/x-custom.raml +0 -33
- package/data/apis/secured-api/x-other.raml +0 -29
- package/data/apis/secured-api/x-query-string.raml +0 -16
- package/data/apis/tracked-examples/datatypes/employee.raml +0 -5
- package/data/apis/tracked-examples/examples/employee.raml +0 -4
- package/data/apis/tracked-examples/examples/employees.raml +0 -8
- package/data/apis/tracked-examples/tracked-to-linked.raml +0 -28
- package/data/model.js +0 -129
- package/data/models/APIC-187.json +0 -11416
- package/data/models/APIC-188.json +0 -11416
- package/data/models/APIC-233.json +0 -539
- package/data/models/APIC-391.json +0 -1903
- package/data/models/APIC-483.json +0 -3110
- package/data/models/APIC-487.json +0 -1225
- package/data/models/APIC-655.json +0 -3145
- package/data/models/APIC-689.json +0 -797
- package/data/models/APIC-690.json +0 -5992
- package/data/models/SE-10469.json +0 -22898
- package/data/models/SE-13092.json +0 -2769
- package/data/models/SE-22063.json +0 -2314
- package/data/models/amf-helper-api.json +0 -84457
- package/data/models/arc-demo-api.json +0 -52041
- package/data/models/async-api.json +0 -3227
- package/data/models/example-generator-api.json +0 -45209
- package/data/models/expanded-api.json +0 -251
- package/data/models/flattened-api.json +0 -251
- package/data/models/multiple-servers.json +0 -2769
- package/data/models/oas-3-api.json +0 -10590
- package/data/models/oas-date.json +0 -637
- package/data/models/oas-types.json +0 -5352
- package/data/models/oas-unions.json +0 -1935
- package/data/models/petstore.json +0 -27712
- package/data/models/raml-date.json +0 -1114
- package/data/models/recursive.json +0 -610
- package/data/models/schema-api.json +0 -35527
- package/data/models/secured-api.json +0 -21071
- package/data/models/tracked-to-linked.json +0 -1914
- package/src/amf/AmfMixin.ts +0 -1726
- package/src/amf/AmfSerializer.ts +0 -2358
- package/src/amf/AmfTypes.ts +0 -147
- package/src/amf/ApiExampleGenerator.ts +0 -122
- package/src/amf/ApiMonacoSchemaGenerator.ts +0 -332
- package/src/amf/ApiSchemaGenerator.ts +0 -115
- package/src/amf/ApiSchemaValues.ts +0 -509
- package/src/amf/Parsing.ts +0 -50
- package/src/amf/Utils.ts +0 -172
- package/src/amf/data-node/DataNodeBase.ts +0 -83
- package/src/amf/data-node/JsonDataNodeGenerator.ts +0 -24
- package/src/amf/data-node/README.md +0 -3
- package/src/amf/data-node/UrlEncodedDataNodeGenerator.ts +0 -49
- package/src/amf/data-node/XmlDataNodeGenerator.ts +0 -46
- package/src/amf/definitions/Amf.ts +0 -440
- package/src/amf/definitions/Api.ts +0 -445
- package/src/amf/definitions/Base.ts +0 -13
- package/src/amf/definitions/Namespace.ts +0 -357
- package/src/amf/definitions/Shapes.ts +0 -438
- package/src/amf/models/AmfDataNode.ts +0 -210
- package/src/amf/shape/README.md +0 -4
- package/src/amf/shape/ShapeBase.ts +0 -174
- package/src/amf/shape/ShapeJsonSchemaGenerator.ts +0 -457
- package/src/amf/shape/ShapeXmlSchemaGenerator.ts +0 -933
- package/src/events/amf/AmfEventTypes.ts +0 -6
- package/src/events/amf/AmfEvents.ts +0 -78
- package/src/mocking/RandExp.ts +0 -335
- package/src/mocking/lib/ret.ts +0 -279
- package/tests/unit/amf/APIC-187.spec.ts +0 -41
- package/tests/unit/amf/APIC-188.spec.ts +0 -30
- package/tests/unit/amf/APIC-233.spec.ts +0 -32
- package/tests/unit/amf/APIC-391.spec.ts +0 -39
- package/tests/unit/amf/APIC-487.spec.ts +0 -44
- package/tests/unit/amf/APIC-655.spec.ts +0 -41
- package/tests/unit/amf/APIC-689.spec.ts +0 -28
- package/tests/unit/amf/APIC-690.spec.ts +0 -93
- package/tests/unit/amf/AmfLoader.ts +0 -538
- package/tests/unit/amf/AmfMixin.spec.ts +0 -1707
- package/tests/unit/amf/ApiExampleGenerator.spec.ts +0 -250
- package/tests/unit/amf/ApiMonacoSchemaGenerator.spec.ts +0 -183
- package/tests/unit/amf/ApiSchemaValues.spec.ts +0 -602
- package/tests/unit/amf/Namepsace.spec.ts +0 -494
- package/tests/unit/amf/SE-10469.spec.ts +0 -35
- package/tests/unit/amf/SE-13092.spec.ts +0 -64
- package/tests/unit/amf/SE-22063.spec.ts +0 -45
- package/tests/unit/amf/raml-examples.spec.ts +0 -43
- package/tests/unit/amf/schema_gen_array.spec.ts +0 -199
- package/tests/unit/amf/schema_gen_oas.spec.ts +0 -140
- package/tests/unit/amf/schema_gen_object.spec.ts +0 -279
- package/tests/unit/amf/schema_gen_scalar.spec.ts +0 -143
- package/tests/unit/amf/schema_gen_union.spec.ts +0 -401
- package/tests/unit/amf/schema_gen_unknown.spec.ts +0 -42
- package/tests/unit/amf/schema_gen_xml.spec.ts +0 -726
- package/tests/unit/amf/serializer/APIC-483.spec.ts +0 -36
- package/tests/unit/amf/serializer/Anotations.spec.ts +0 -50
- package/tests/unit/amf/serializer/Api.spec.ts +0 -210
- package/tests/unit/amf/serializer/Documentation.spec.ts +0 -52
- package/tests/unit/amf/serializer/Endpoints.spec.ts +0 -172
- package/tests/unit/amf/serializer/Operations.spec.ts +0 -330
- package/tests/unit/amf/serializer/Parameters.spec.ts +0 -149
- package/tests/unit/amf/serializer/PayloadExamples.spec.ts +0 -152
- package/tests/unit/amf/serializer/Security.spec.ts +0 -626
- package/tests/unit/amf/serializer/Server.spec.ts +0 -78
- package/tests/unit/amf/serializer/Shapes.spec.ts +0 -304
- package/tests/unit/amf/serializer/SourceMaps.spec.ts +0 -52
- package/tests/unit/amf/shapes/ShapeXmlSchemaGenerator.spec.ts +0 -28
- package/tests/unit/amf/tracked-to-linked.spec.ts +0 -90
- package/tests/unit/amf/xml-data-processing.spec.ts +0 -217
- package/tests/unit/events/amf.spec.ts +0 -151
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AmfTypes.js","sourceRoot":"","sources":["../../../src/amf/AmfTypes.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAA;AAEzD,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,YAAY,CAAC,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,WAAW;IAChD,YAAY,CAAC,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,QAAQ;IAC7C,YAAY,CAAC,EAAE,CAAC,KAAK,CAAC,KAAK;IAC3B,YAAY,CAAC,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,KAAK;IAC1C,YAAY,CAAC,GAAG,CAAC,YAAY,CAAC,QAAQ,CAAC,aAAa;CACrD,CAAA;AACD,MAAM,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AC;QACxB,OAAO,YAAY,CAAC,EAAE,CAAC,SAAS,CAAC,QAAQ,CAAA;IAC3C,CAAC;IACD,IAAI,IAAI,KAAK,MAAM,EAAE,CAAC;QACpB,OAAO,YAAY,CAAC,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,YAAY,CAAA;IAC1D,CAAC;IACD,IAAI,IAAI,KAAK,QAAQ,IAAI,QAAQ,IAAI,QAAQ,CAAC,MAAM,KAAK,QAAQ,EAAE,CAAC;QAClE,OAAO,YAAY,CAAC,EAAE,CAAC,SAAS,CAAC,YAAY,CAAA;IAC/C,CAAC;IACD,OAAO,YAAY,CAAC,EAAE,CAAC,SAAS,CAAC,MAAM,CAAA;IACvC,kBAAkB;IAClB,mBAAmB;IACnB,yDAAyD;IACzD,mBAAmB;IACnB,8DAA8D;IAC9D,aAAa;IACb,2EAA2E;IAC3E,sDAAsD;IACtD,QAAQ;IACR,yDAAyD;IACzD,yDAAyD;IACzD,WAAW;IACX,8CAA8C;IAC9C,IAAI;AACN,CAAC","sourcesContent":["import { type DomainPropertyType } from '../modeling/DataFormat.js'\nimport { PropertyWebBindings } from '../modeling/Bindings.js'\nimport { AmfNamespace } from './definitions/Namespace.js'\n\nexport const IAmfScalarTypes = [\n AmfNamespace.aml.vocabularies.shapes.ScalarShape,\n AmfNamespace.aml.vocabularies.shapes.AnyShape,\n AmfNamespace.w3.shacl.Shape,\n AmfNamespace.aml.vocabularies.shapes.Shape,\n AmfNamespace.aml.vocabularies.document.DomainElement,\n]\nexport const IAmfArrayTypes = [\n AmfNamespace.aml.vocabularies.shapes.ArrayShape,\n AmfNamespace.aml.vocabularies.shapes.AnyShape,\n AmfNamespace.w3.shacl.Shape,\n AmfNamespace.aml.vocabularies.shapes.Shape,\n AmfNamespace.aml.vocabularies.document.DomainElement,\n]\nexport const IAmfNodeTypes = [\n AmfNamespace.w3.shacl.NodeShape,\n AmfNamespace.aml.vocabularies.shapes.AnyShape,\n AmfNamespace.w3.shacl.Shape,\n AmfNamespace.aml.vocabularies.shapes.Shape,\n AmfNamespace.aml.vocabularies.document.DomainElement,\n]\nexport const IAmfPropertyTypes = [\n AmfNamespace.w3.shacl.PropertyShape,\n AmfNamespace.w3.shacl.Shape,\n AmfNamespace.aml.vocabularies.shapes.Shape,\n AmfNamespace.aml.vocabularies.document.DomainElement,\n]\nexport const IAmfNilTypes = [\n AmfNamespace.aml.vocabularies.shapes.NilShape,\n AmfNamespace.w3.shacl.Shape,\n AmfNamespace.aml.vocabularies.shapes.Shape,\n AmfNamespace.aml.vocabularies.document.DomainElement,\n]\nexport const IAmfUnionTypes = [\n AmfNamespace.aml.vocabularies.shapes.UnionShape,\n AmfNamespace.aml.vocabularies.shapes.AnyShape,\n AmfNamespace.w3.shacl.Shape,\n AmfNamespace.aml.vocabularies.shapes.Shape,\n AmfNamespace.aml.vocabularies.document.DomainElement,\n]\nexport const IAmfFileTypes = [\n AmfNamespace.aml.vocabularies.shapes.FileShape,\n AmfNamespace.aml.vocabularies.shapes.AnyShape,\n AmfNamespace.w3.shacl.Shape,\n AmfNamespace.aml.vocabularies.shapes.Shape,\n AmfNamespace.aml.vocabularies.document.DomainElement,\n]\nexport const IAmfAnyTypes = [\n AmfNamespace.aml.vocabularies.shapes.AnyShape,\n AmfNamespace.w3.shacl.Shape,\n AmfNamespace.aml.vocabularies.shapes.Shape,\n AmfNamespace.aml.vocabularies.document.DomainElement,\n]\nexport const IAmfSchemaTypes = [\n AmfNamespace.aml.vocabularies.shapes.SchemaShape,\n AmfNamespace.aml.vocabularies.shapes.AnyShape,\n AmfNamespace.w3.shacl.Shape,\n AmfNamespace.aml.vocabularies.shapes.Shape,\n AmfNamespace.aml.vocabularies.document.DomainElement,\n]\nexport const IAmfTupleTypes = [\n AmfNamespace.aml.vocabularies.shapes.TupleShape,\n AmfNamespace.aml.vocabularies.shapes.ArrayShape,\n AmfNamespace.aml.vocabularies.shapes.AnyShape,\n AmfNamespace.w3.shacl.Shape,\n AmfNamespace.aml.vocabularies.shapes.Shape,\n AmfNamespace.aml.vocabularies.document.DomainElement,\n]\nexport const IAmfRecursiveTypes = [\n AmfNamespace.aml.vocabularies.shapes.RecursiveShape,\n AmfNamespace.w3.shacl.Shape,\n AmfNamespace.aml.vocabularies.shapes.Shape,\n AmfNamespace.aml.vocabularies.document.DomainElement,\n]\nexport const IAmfXmlSerializationTypes = [\n AmfNamespace.aml.vocabularies.shapes.XMLSerializer,\n AmfNamespace.aml.vocabularies.document.DomainElement,\n]\n\nexport const IAmfScalarNodeTypes = [\n AmfNamespace.aml.vocabularies.data.Scalar,\n AmfNamespace.aml.vocabularies.data.Node,\n AmfNamespace.aml.vocabularies.document.DomainElement,\n]\nexport const IAmfArrayNodeTypes = [\n AmfNamespace.aml.vocabularies.data.Array,\n AmfNamespace.w3.rdfSchema.Seq,\n AmfNamespace.aml.vocabularies.data.Node,\n AmfNamespace.aml.vocabularies.document.DomainElement,\n]\nexport const IAmfObjectNodeTypes = [\n AmfNamespace.aml.vocabularies.data.Object,\n AmfNamespace.aml.vocabularies.data.Node,\n AmfNamespace.aml.vocabularies.document.DomainElement,\n]\nexport const IAmfExampleTypes = [\n AmfNamespace.aml.vocabularies.apiContract.Example,\n AmfNamespace.aml.vocabularies.document.DomainElement,\n]\n\n/**\n * Translates the DomainProperty type to an AMF data type.\n * @param type The property data type\n * @returns AMF shape dataType\n */\nexport function modelTypeToAmfDataType(type: DomainPropertyType, bindings?: PropertyWebBindings): string {\n if (type === 'number') {\n if (bindings?.format === 'int32' || bindings?.format === 'int64') {\n return AmfNamespace.w3.xmlSchema.integer\n }\n return AmfNamespace.w3.xmlSchema.number\n }\n if (type === 'boolean') {\n return AmfNamespace.aml.vocabularies.shapes.boolean\n }\n if (type === 'date') {\n return AmfNamespace.w3.xmlSchema.date\n }\n if (type === 'datetime') {\n return AmfNamespace.w3.xmlSchema.dateTime\n }\n if (type === 'time') {\n return AmfNamespace.aml.vocabularies.shapes.dateTimeOnly\n }\n if (type === 'binary' && bindings && bindings.format === 'base64') {\n return AmfNamespace.w3.xmlSchema.base64Binary\n }\n return AmfNamespace.w3.xmlSchema.string\n // switch (type) {\n // // case 'nil':\n // // return AmfNamespace.aml.vocabularies.shapes.nil\n // // case 'any':\n // // return AmfNamespace.aml.vocabularies.shapes.AnyShape\n // default:\n // if (type === 'binary' && bindings && bindings.format === 'base64') {\n // return AmfNamespace.w3.xmlSchema.base64Binary\n // }\n // // if (bindings && bindings.format === 'binary') {\n // // return AmfNamespace.w3.xmlSchema.base64Binary\n // // }\n // return AmfNamespace.w3.xmlSchema.string\n // }\n}\n"]}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { IApiDataExample, IApiDataNode, IShapeUnion } from './definitions/Shapes.js';
|
|
2
|
-
/**
|
|
3
|
-
* A class that processes AMF's Example object to read the example value
|
|
4
|
-
* or to generate the example for the given media type.
|
|
5
|
-
*/
|
|
6
|
-
export declare class ApiExampleGenerator {
|
|
7
|
-
/**
|
|
8
|
-
* Reads or generates an example.
|
|
9
|
-
* When the `mime` is set then it tries to "guess" whether the mime type corresponds to the value.
|
|
10
|
-
* If it doesn't then it generates the example from the structured value, when possible.
|
|
11
|
-
* @param example The structured value of the example
|
|
12
|
-
* @param mime The optional mime type of the example. When not set it
|
|
13
|
-
* won't generate example from the structured value.
|
|
14
|
-
* @param shape The optional shape containing this example to use with the
|
|
15
|
-
* XML examples which needs wrapping into an element.
|
|
16
|
-
* @returns The read or generated example.
|
|
17
|
-
*/
|
|
18
|
-
read(example: IApiDataExample, mime?: string, shape?: IShapeUnion): string | number | false | null | undefined;
|
|
19
|
-
/**
|
|
20
|
-
* Employs some basic heuristics to determine whether the given mime type patches the content.
|
|
21
|
-
* @param mime The mime type for the value.
|
|
22
|
-
* @param value The value.
|
|
23
|
-
* @returns True when the value matches the mime type.
|
|
24
|
-
*/
|
|
25
|
-
mimeMatches(mime: string, value?: string): boolean;
|
|
26
|
-
/**
|
|
27
|
-
* Generates the example for the given structured value and the media type.
|
|
28
|
-
* @param mime The mime type for the value.
|
|
29
|
-
* @param structuredValue The structuredValue of the example.
|
|
30
|
-
* @param shape The optional shape containing this example to use with the
|
|
31
|
-
* XML examples which needs wrapping into an element.
|
|
32
|
-
* @returns The generated example or null if couldn't process the data.
|
|
33
|
-
*/
|
|
34
|
-
fromStructuredValue(mime: string, structuredValue: IApiDataNode, shape?: IShapeUnion): string | number | false | null | undefined;
|
|
35
|
-
/**
|
|
36
|
-
* Wraps the generated XML example into an element according to the `shape` properties.
|
|
37
|
-
*/
|
|
38
|
-
wrapXmlValue(value?: string | number | false | null | undefined, shape?: IShapeUnion): string | number | false | null | undefined;
|
|
39
|
-
}
|
|
40
|
-
//# sourceMappingURL=ApiExampleGenerator.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ApiExampleGenerator.d.ts","sourceRoot":"","sources":["../../../src/amf/ApiExampleGenerator.ts"],"names":[],"mappings":"AAKA,OAAO,EAAkB,eAAe,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AAEpG;;;GAGG;AACH,qBAAa,mBAAmB;IAC9B;;;;;;;;;;OAUG;IACH,IAAI,CAAC,OAAO,EAAE,eAAe,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,WAAW,GAAG,MAAM,GAAG,MAAM,GAAG,KAAK,GAAG,IAAI,GAAG,SAAS;IAoB9G;;;;;OAKG;IACH,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO;IAelD;;;;;;;OAOG;IACH,mBAAmB,CACjB,IAAI,EAAE,MAAM,EACZ,eAAe,EAAE,YAAY,EAC7B,KAAK,CAAC,EAAE,WAAW,GAClB,MAAM,GAAG,MAAM,GAAG,KAAK,GAAG,IAAI,GAAG,SAAS;IA6B7C;;OAEG;IACH,YAAY,CACV,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,KAAK,GAAG,IAAI,GAAG,SAAS,EAClD,KAAK,CAAC,EAAE,WAAW,GAClB,MAAM,GAAG,MAAM,GAAG,KAAK,GAAG,IAAI,GAAG,SAAS;CAU9C"}
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
import { AmfNamespace as ns } from './definitions/Namespace.js';
|
|
2
|
-
import { JsonDataNodeGenerator } from './data-node/JsonDataNodeGenerator.js';
|
|
3
|
-
import { XmlDataNodeGenerator } from './data-node/XmlDataNodeGenerator.js';
|
|
4
|
-
import { UrlEncodedDataNodeGenerator } from './data-node/UrlEncodedDataNodeGenerator.js';
|
|
5
|
-
import { formatXmlValue } from './Utils.js';
|
|
6
|
-
/**
|
|
7
|
-
* A class that processes AMF's Example object to read the example value
|
|
8
|
-
* or to generate the example for the given media type.
|
|
9
|
-
*/
|
|
10
|
-
export class ApiExampleGenerator {
|
|
11
|
-
/**
|
|
12
|
-
* Reads or generates an example.
|
|
13
|
-
* When the `mime` is set then it tries to "guess" whether the mime type corresponds to the value.
|
|
14
|
-
* If it doesn't then it generates the example from the structured value, when possible.
|
|
15
|
-
* @param example The structured value of the example
|
|
16
|
-
* @param mime The optional mime type of the example. When not set it
|
|
17
|
-
* won't generate example from the structured value.
|
|
18
|
-
* @param shape The optional shape containing this example to use with the
|
|
19
|
-
* XML examples which needs wrapping into an element.
|
|
20
|
-
* @returns The read or generated example.
|
|
21
|
-
*/
|
|
22
|
-
read(example, mime, shape) {
|
|
23
|
-
const { value, structuredValue } = example;
|
|
24
|
-
if (!value && !structuredValue) {
|
|
25
|
-
return undefined;
|
|
26
|
-
}
|
|
27
|
-
if (structuredValue && !value && mime) {
|
|
28
|
-
return this.fromStructuredValue(mime, structuredValue, shape);
|
|
29
|
-
}
|
|
30
|
-
if (!mime) {
|
|
31
|
-
return value;
|
|
32
|
-
}
|
|
33
|
-
if (this.mimeMatches(mime, value)) {
|
|
34
|
-
return value;
|
|
35
|
-
}
|
|
36
|
-
if (structuredValue) {
|
|
37
|
-
return this.fromStructuredValue(mime, structuredValue, shape);
|
|
38
|
-
}
|
|
39
|
-
return undefined;
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Employs some basic heuristics to determine whether the given mime type patches the content.
|
|
43
|
-
* @param mime The mime type for the value.
|
|
44
|
-
* @param value The value.
|
|
45
|
-
* @returns True when the value matches the mime type.
|
|
46
|
-
*/
|
|
47
|
-
mimeMatches(mime, value) {
|
|
48
|
-
const trimmed = String(value).trim();
|
|
49
|
-
if (mime.includes('json')) {
|
|
50
|
-
// JSON string has to start with either of these characters
|
|
51
|
-
return trimmed[0] === '{' || trimmed[0] === '[';
|
|
52
|
-
}
|
|
53
|
-
if (mime.includes('xml')) {
|
|
54
|
-
return trimmed.startsWith('<');
|
|
55
|
-
}
|
|
56
|
-
if (mime.includes('x-www-form-urlencoded')) {
|
|
57
|
-
return trimmed.includes('=') || trimmed.includes('&');
|
|
58
|
-
}
|
|
59
|
-
return true;
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Generates the example for the given structured value and the media type.
|
|
63
|
-
* @param mime The mime type for the value.
|
|
64
|
-
* @param structuredValue The structuredValue of the example.
|
|
65
|
-
* @param shape The optional shape containing this example to use with the
|
|
66
|
-
* XML examples which needs wrapping into an element.
|
|
67
|
-
* @returns The generated example or null if couldn't process the data.
|
|
68
|
-
*/
|
|
69
|
-
fromStructuredValue(mime, structuredValue, shape) {
|
|
70
|
-
if (mime.includes('json')) {
|
|
71
|
-
const generator = new JsonDataNodeGenerator();
|
|
72
|
-
return generator.generate(structuredValue);
|
|
73
|
-
}
|
|
74
|
-
let shapeName;
|
|
75
|
-
if (shape && shape.types.includes(ns.aml.vocabularies.shapes.ScalarShape)) {
|
|
76
|
-
shapeName = shape.name;
|
|
77
|
-
}
|
|
78
|
-
else if (shape && shape.types.includes(ns.aml.vocabularies.shapes.ArrayShape)) {
|
|
79
|
-
const typed = shape;
|
|
80
|
-
if (typed.items && typed.items.types.includes(ns.aml.vocabularies.shapes.ScalarShape)) {
|
|
81
|
-
shapeName = typed.items.name || shape.name;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
if (mime.includes('xml')) {
|
|
85
|
-
const generator = new XmlDataNodeGenerator();
|
|
86
|
-
let value = generator.generate(structuredValue, shapeName);
|
|
87
|
-
if (shape && !shapeName) {
|
|
88
|
-
value = this.wrapXmlValue(value, shape);
|
|
89
|
-
}
|
|
90
|
-
return value;
|
|
91
|
-
}
|
|
92
|
-
if (mime.includes('x-www-form-urlencoded')) {
|
|
93
|
-
const generator = new UrlEncodedDataNodeGenerator();
|
|
94
|
-
return generator.generate(structuredValue, shapeName);
|
|
95
|
-
}
|
|
96
|
-
return undefined;
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* Wraps the generated XML example into an element according to the `shape` properties.
|
|
100
|
-
*/
|
|
101
|
-
wrapXmlValue(value, shape) {
|
|
102
|
-
if (!value || !shape) {
|
|
103
|
-
return value;
|
|
104
|
-
}
|
|
105
|
-
const { name } = shape;
|
|
106
|
-
const parts = [`<${name}>`];
|
|
107
|
-
parts.push(formatXmlValue(' ', String(value).trim()));
|
|
108
|
-
parts.push(`</${name}>`);
|
|
109
|
-
return parts.join('\n');
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
//# sourceMappingURL=ApiExampleGenerator.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ApiExampleGenerator.js","sourceRoot":"","sources":["../../../src/amf/ApiExampleGenerator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,IAAI,EAAE,EAAE,MAAM,4BAA4B,CAAA;AAC/D,OAAO,EAAE,qBAAqB,EAAE,MAAM,sCAAsC,CAAA;AAC5E,OAAO,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAA;AAC1E,OAAO,EAAE,2BAA2B,EAAE,MAAM,4CAA4C,CAAA;AACxF,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAG3C;;;GAGG;AACH,MAAM,OAAO,mBA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AAK,IAAI,CAAC,SAAS,EAAE,CAAC;gBACxB,KAAK,GAAG,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,KAAK,CAAC,CAAA;YACzC,CAAC;YACD,OAAO,KAAK,CAAA;QACd,CAAC;QACD,IAAI,IAAI,CAAC,QAAQ,CAAC,uBAAuB,CAAC,EAAE,CAAC;YAC3C,MAAM,SAAS,GAAG,IAAI,2BAA2B,EAAE,CAAA;YACnD,OAAO,SAAS,CAAC,QAAQ,CAAC,eAAe,EAAE,SAAS,CAAC,CAAA;QACvD,CAAC;QACD,OAAO,SAAS,CAAA;IAClB,CAAC;IAED;;OAEG;IACH,YAAY,CACV,KAAkD,EAClD,KAAmB;QAEnB,IAAI,CAAC,KAAK,IAAI,CAAC,KAAK,EAAE,CAAC;YACrB,OAAO,KAAK,CAAA;QACd,CAAC;QACD,MAAM,EAAE,IAAI,EAAE,GAAG,KAAK,CAAA;QACtB,MAAM,KAAK,GAAG,CAAC,IAAI,IAAI,GAAG,CAAC,CAAA;QAC3B,KAAK,CAAC,IAAI,CAAC,cAAc,CAAC,IAAI,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAA;QACtD,KAAK,CAAC,IAAI,CAAC,KAAK,IAAI,GAAG,CAAC,CAAA;QACxB,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IACzB,CAAC;CACF","sourcesContent":["import { AmfNamespace as ns } from './definitions/Namespace.js'\nimport { JsonDataNodeGenerator } from './data-node/JsonDataNodeGenerator.js'\nimport { XmlDataNodeGenerator } from './data-node/XmlDataNodeGenerator.js'\nimport { UrlEncodedDataNodeGenerator } from './data-node/UrlEncodedDataNodeGenerator.js'\nimport { formatXmlValue } from './Utils.js'\nimport { IApiArrayShape, IApiDataExample, IApiDataNode, IShapeUnion } from './definitions/Shapes.js'\n\n/**\n * A class that processes AMF's Example object to read the example value\n * or to generate the example for the given media type.\n */\nexport class ApiExampleGenerator {\n /**\n * Reads or generates an example.\n * When the `mime` is set then it tries to \"guess\" whether the mime type corresponds to the value.\n * If it doesn't then it generates the example from the structured value, when possible.\n * @param example The structured value of the example\n * @param mime The optional mime type of the example. When not set it\n * won't generate example from the structured value.\n * @param shape The optional shape containing this example to use with the\n * XML examples which needs wrapping into an element.\n * @returns The read or generated example.\n */\n read(example: IApiDataExample, mime?: string, shape?: IShapeUnion): string | number | false | null | undefined {\n const { value, structuredValue } = example\n if (!value && !structuredValue) {\n return undefined\n }\n if (structuredValue && !value && mime) {\n return this.fromStructuredValue(mime, structuredValue, shape)\n }\n if (!mime) {\n return value\n }\n if (this.mimeMatches(mime, value)) {\n return value\n }\n if (structuredValue) {\n return this.fromStructuredValue(mime, structuredValue, shape)\n }\n return undefined\n }\n\n /**\n * Employs some basic heuristics to determine whether the given mime type patches the content.\n * @param mime The mime type for the value.\n * @param value The value.\n * @returns True when the value matches the mime type.\n */\n mimeMatches(mime: string, value?: string): boolean {\n const trimmed = String(value).trim()\n if (mime.includes('json')) {\n // JSON string has to start with either of these characters\n return trimmed[0] === '{' || trimmed[0] === '['\n }\n if (mime.includes('xml')) {\n return trimmed.startsWith('<')\n }\n if (mime.includes('x-www-form-urlencoded')) {\n return trimmed.includes('=') || trimmed.includes('&')\n }\n return true\n }\n\n /**\n * Generates the example for the given structured value and the media type.\n * @param mime The mime type for the value.\n * @param structuredValue The structuredValue of the example.\n * @param shape The optional shape containing this example to use with the\n * XML examples which needs wrapping into an element.\n * @returns The generated example or null if couldn't process the data.\n */\n fromStructuredValue(\n mime: string,\n structuredValue: IApiDataNode,\n shape?: IShapeUnion\n ): string | number | false | null | undefined {\n if (mime.includes('json')) {\n const generator = new JsonDataNodeGenerator()\n return generator.generate(structuredValue)\n }\n let shapeName\n if (shape && shape.types.includes(ns.aml.vocabularies.shapes.ScalarShape)) {\n shapeName = shape.name\n } else if (shape && shape.types.includes(ns.aml.vocabularies.shapes.ArrayShape)) {\n const typed = shape as IApiArrayShape\n if (typed.items && typed.items.types.includes(ns.aml.vocabularies.shapes.ScalarShape)) {\n shapeName = typed.items.name || shape.name\n }\n }\n if (mime.includes('xml')) {\n const generator = new XmlDataNodeGenerator()\n let value = generator.generate(structuredValue, shapeName)\n if (shape && !shapeName) {\n value = this.wrapXmlValue(value, shape)\n }\n return value\n }\n if (mime.includes('x-www-form-urlencoded')) {\n const generator = new UrlEncodedDataNodeGenerator()\n return generator.generate(structuredValue, shapeName)\n }\n return undefined\n }\n\n /**\n * Wraps the generated XML example into an element according to the `shape` properties.\n */\n wrapXmlValue(\n value?: string | number | false | null | undefined,\n shape?: IShapeUnion\n ): string | number | false | null | undefined {\n if (!value || !shape) {\n return value\n }\n const { name } = shape\n const parts = [`<${name}>`]\n parts.push(formatXmlValue(' ', String(value).trim()))\n parts.push(`</${name}>`)\n return parts.join('\\n')\n }\n}\n"]}
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import { IApiArrayShape, IApiNodeShape, IApiPropertyShape, IApiScalarShape, IShapeUnion } from './definitions/Shapes.js';
|
|
2
|
-
export interface IMonacoSchema {
|
|
3
|
-
uri: string;
|
|
4
|
-
schema: IMonacoProperty;
|
|
5
|
-
fileMatch?: string[];
|
|
6
|
-
}
|
|
7
|
-
export interface IMonacoProperty {
|
|
8
|
-
$id?: string;
|
|
9
|
-
title: string;
|
|
10
|
-
type: string;
|
|
11
|
-
description?: string;
|
|
12
|
-
readOnly?: boolean;
|
|
13
|
-
writeOnly?: boolean;
|
|
14
|
-
}
|
|
15
|
-
export interface IMonacoScalarProperty extends IMonacoProperty {
|
|
16
|
-
default?: string;
|
|
17
|
-
pattern?: string;
|
|
18
|
-
format?: string;
|
|
19
|
-
exclusiveMaximum?: boolean;
|
|
20
|
-
exclusiveMinimum?: boolean;
|
|
21
|
-
maxLength?: number;
|
|
22
|
-
minLength?: number;
|
|
23
|
-
minimum?: number;
|
|
24
|
-
maximum?: number;
|
|
25
|
-
multipleOf?: number;
|
|
26
|
-
enum?: string[];
|
|
27
|
-
}
|
|
28
|
-
export interface IMonacoObjectProperty extends IMonacoProperty {
|
|
29
|
-
properties: Record<string, IMonacoProperty>;
|
|
30
|
-
required: string[];
|
|
31
|
-
additionalProperties?: boolean;
|
|
32
|
-
minProperties?: number;
|
|
33
|
-
maxProperties?: number;
|
|
34
|
-
}
|
|
35
|
-
export interface IMonacoArrayProperty extends IMonacoProperty {
|
|
36
|
-
additionalItems?: boolean;
|
|
37
|
-
items: {
|
|
38
|
-
anyOf: IMonacoProperty[];
|
|
39
|
-
};
|
|
40
|
-
uniqueItems?: boolean;
|
|
41
|
-
minItems?: number;
|
|
42
|
-
maxItems?: number;
|
|
43
|
-
required: string[];
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* A class to generate JSON schema from an ApiShapeUnion declaration to use with the Monaco editor schemas.
|
|
47
|
-
*/
|
|
48
|
-
export declare class ApiMonacoSchemaGenerator {
|
|
49
|
-
schemas: IMonacoSchema[];
|
|
50
|
-
/**
|
|
51
|
-
* @param parentUri The URI for the fileMatch property.
|
|
52
|
-
*/
|
|
53
|
-
generate(schema: IShapeUnion, parentUri: string): IMonacoSchema[];
|
|
54
|
-
/**
|
|
55
|
-
* @param parentUri The URI for the fileMatch property.
|
|
56
|
-
*/
|
|
57
|
-
fromNodeShape(schema: IApiNodeShape, parentUri?: string): IMonacoSchema[];
|
|
58
|
-
appendSchemaProperty(content: IMonacoObjectProperty, property: IApiPropertyShape): void;
|
|
59
|
-
rangeToPropertySchema(range: IShapeUnion): IMonacoScalarProperty | IMonacoObjectProperty | IMonacoArrayProperty | undefined;
|
|
60
|
-
scalarRangeToPropertySchema(schema: IApiScalarShape): IMonacoScalarProperty;
|
|
61
|
-
/**
|
|
62
|
-
* Translates AMF data type to JSON schema data type.
|
|
63
|
-
*/
|
|
64
|
-
schemaTypeToJsonDataType(schemaType?: string): string;
|
|
65
|
-
nodeShapeRangeToPropertySchema(schema: IApiNodeShape): IMonacoObjectProperty;
|
|
66
|
-
arrayShapeRangeToPropertySchema(schema: IApiArrayShape): IMonacoArrayProperty;
|
|
67
|
-
}
|
|
68
|
-
//# sourceMappingURL=ApiMonacoSchemaGenerator.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ApiMonacoSchemaGenerator.d.ts","sourceRoot":"","sources":["../../../src/amf/ApiMonacoSchemaGenerator.ts"],"names":[],"mappings":"AACA,OAAO,EACL,cAAc,EACd,aAAa,EACb,iBAAiB,EAEjB,eAAe,EACf,WAAW,EACZ,MAAM,yBAAyB,CAAA;AAGhC,MAAM,WAAW,aAAa;IAC5B,GAAG,EAAE,MAAM,CAAA;IACX,MAAM,EAAE,eAAe,CAAA;IACvB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAA;CACrB;AAED,MAAM,WAAW,eAAe;IAC9B,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,SAAS,CAAC,EAAE,OAAO,CAAA;CACpB;AAED,MAAM,WAAW,qBAAsB,SAAQ,eAAe;IAC5D,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,gBAAgB,CAAC,EAAE,OAAO,CAAA;IAC1B,gBAAgB,CAAC,EAAE,OAAO,CAAA;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAA;CAChB;AAED,MAAM,WAAW,qBAAsB,SAAQ,eAAe;IAC5D,UAAU,EAAE,MAAM,CAAC,MA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|
|
2
|
-
import { collectNodeProperties } from './Utils.js';
|
|
3
|
-
function cleanName(name) {
|
|
4
|
-
if (!name) {
|
|
5
|
-
return '';
|
|
6
|
-
}
|
|
7
|
-
return name.replace('?', '');
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* A class to generate JSON schema from an ApiShapeUnion declaration to use with the Monaco editor schemas.
|
|
11
|
-
*/
|
|
12
|
-
export class ApiMonacoSchemaGenerator {
|
|
13
|
-
schemas = [];
|
|
14
|
-
/**
|
|
15
|
-
* @param parentUri The URI for the fileMatch property.
|
|
16
|
-
*/
|
|
17
|
-
generate(schema, parentUri) {
|
|
18
|
-
this.schemas = [];
|
|
19
|
-
if (!schema) {
|
|
20
|
-
return [];
|
|
21
|
-
}
|
|
22
|
-
const { types } = schema;
|
|
23
|
-
if (types.includes(ns.w3.shacl.NodeShape)) {
|
|
24
|
-
return this.fromNodeShape(schema, parentUri);
|
|
25
|
-
}
|
|
26
|
-
return [];
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* @param parentUri The URI for the fileMatch property.
|
|
30
|
-
*/
|
|
31
|
-
fromNodeShape(schema, parentUri) {
|
|
32
|
-
const { id, name } = schema;
|
|
33
|
-
const properties = collectNodeProperties(schema);
|
|
34
|
-
const content = {
|
|
35
|
-
title: cleanName(name),
|
|
36
|
-
type: 'object',
|
|
37
|
-
properties: {},
|
|
38
|
-
required: [],
|
|
39
|
-
};
|
|
40
|
-
const result = {
|
|
41
|
-
uri: id,
|
|
42
|
-
schema: content,
|
|
43
|
-
};
|
|
44
|
-
if (parentUri) {
|
|
45
|
-
result.fileMatch = [parentUri];
|
|
46
|
-
}
|
|
47
|
-
this.schemas.push(result);
|
|
48
|
-
if (!Array.isArray(properties) || !properties.length) {
|
|
49
|
-
return this.schemas;
|
|
50
|
-
}
|
|
51
|
-
properties.forEach((property) => this.appendSchemaProperty(content, property));
|
|
52
|
-
return this.schemas;
|
|
53
|
-
}
|
|
54
|
-
appendSchemaProperty(content, property) {
|
|
55
|
-
const { name, range, minCount } = property;
|
|
56
|
-
if (!range) {
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
const value = this.rangeToPropertySchema(range);
|
|
60
|
-
if (value && name) {
|
|
61
|
-
content.properties[name] = value;
|
|
62
|
-
if (minCount === 1) {
|
|
63
|
-
content.required.push(name);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
rangeToPropertySchema(range) {
|
|
68
|
-
const { types } = range;
|
|
69
|
-
if (types.includes(ns.aml.vocabularies.shapes.ScalarShape)) {
|
|
70
|
-
return this.scalarRangeToPropertySchema(range);
|
|
71
|
-
}
|
|
72
|
-
if (types.includes(ns.w3.shacl.NodeShape)) {
|
|
73
|
-
return this.nodeShapeRangeToPropertySchema(range);
|
|
74
|
-
}
|
|
75
|
-
if (types.includes(ns.aml.vocabularies.shapes.ArrayShape)) {
|
|
76
|
-
return this.arrayShapeRangeToPropertySchema(range);
|
|
77
|
-
}
|
|
78
|
-
return undefined;
|
|
79
|
-
}
|
|
80
|
-
scalarRangeToPropertySchema(schema) {
|
|
81
|
-
const { values, description, name, displayName, defaultValueStr, exclusiveMaximum, exclusiveMinimum, minimum, maximum, minLength, maxLength, id, multipleOf, pattern, readOnly, writeOnly, } = schema;
|
|
82
|
-
const type = this.schemaTypeToJsonDataType(schema.dataType);
|
|
83
|
-
const result = {
|
|
84
|
-
$id: id,
|
|
85
|
-
type,
|
|
86
|
-
title: cleanName(displayName || name),
|
|
87
|
-
};
|
|
88
|
-
if (description) {
|
|
89
|
-
result.description = description;
|
|
90
|
-
}
|
|
91
|
-
if (defaultValueStr) {
|
|
92
|
-
result.default = defaultValueStr;
|
|
93
|
-
}
|
|
94
|
-
if (typeof exclusiveMaximum === 'boolean') {
|
|
95
|
-
result.exclusiveMaximum = exclusiveMaximum;
|
|
96
|
-
}
|
|
97
|
-
if (typeof exclusiveMinimum === 'boolean') {
|
|
98
|
-
result.exclusiveMinimum = exclusiveMinimum;
|
|
99
|
-
}
|
|
100
|
-
if (typeof maxLength === 'number') {
|
|
101
|
-
result.maxLength = maxLength;
|
|
102
|
-
}
|
|
103
|
-
if (typeof minLength === 'number') {
|
|
104
|
-
result.minLength = minLength;
|
|
105
|
-
}
|
|
106
|
-
if (typeof minimum === 'number') {
|
|
107
|
-
result.minimum = minimum;
|
|
108
|
-
}
|
|
109
|
-
if (typeof maximum === 'number') {
|
|
110
|
-
result.maximum = maximum;
|
|
111
|
-
}
|
|
112
|
-
if (typeof multipleOf === 'number') {
|
|
113
|
-
result.multipleOf = multipleOf;
|
|
114
|
-
}
|
|
115
|
-
if (typeof pattern === 'string') {
|
|
116
|
-
result.pattern = pattern;
|
|
117
|
-
}
|
|
118
|
-
if (typeof readOnly === 'boolean') {
|
|
119
|
-
result.readOnly = readOnly;
|
|
120
|
-
}
|
|
121
|
-
if (typeof writeOnly === 'boolean') {
|
|
122
|
-
result.writeOnly = writeOnly;
|
|
123
|
-
}
|
|
124
|
-
switch (schema.dataType) {
|
|
125
|
-
case ns.aml.vocabularies.shapes.dateTimeOnly:
|
|
126
|
-
result.format = 'date-time';
|
|
127
|
-
break;
|
|
128
|
-
case ns.w3.xmlSchema.date:
|
|
129
|
-
result.format = 'date';
|
|
130
|
-
break;
|
|
131
|
-
case ns.w3.xmlSchema.time:
|
|
132
|
-
result.format = 'time';
|
|
133
|
-
break;
|
|
134
|
-
default:
|
|
135
|
-
}
|
|
136
|
-
if (Array.isArray(values) && values.length) {
|
|
137
|
-
// enum properties
|
|
138
|
-
result.enum = [];
|
|
139
|
-
values.forEach((value) => {
|
|
140
|
-
const { types } = value;
|
|
141
|
-
if (types.includes(ns.aml.vocabularies.data.Scalar)) {
|
|
142
|
-
const typed = value;
|
|
143
|
-
if (typed.value) {
|
|
144
|
-
;
|
|
145
|
-
result.enum.push(typed.value);
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
|
-
return result;
|
|
151
|
-
}
|
|
152
|
-
/**
|
|
153
|
-
* Translates AMF data type to JSON schema data type.
|
|
154
|
-
*/
|
|
155
|
-
schemaTypeToJsonDataType(schemaType) {
|
|
156
|
-
switch (schemaType) {
|
|
157
|
-
case ns.aml.vocabularies.shapes.number:
|
|
158
|
-
case ns.aml.vocabularies.shapes.integer:
|
|
159
|
-
case ns.aml.vocabularies.shapes.float:
|
|
160
|
-
case ns.aml.vocabularies.shapes.long:
|
|
161
|
-
case ns.aml.vocabularies.shapes.double:
|
|
162
|
-
case ns.w3.xmlSchema.number:
|
|
163
|
-
case ns.w3.xmlSchema.integer:
|
|
164
|
-
case ns.w3.xmlSchema.float:
|
|
165
|
-
case ns.w3.xmlSchema.long:
|
|
166
|
-
case ns.w3.xmlSchema.double:
|
|
167
|
-
return 'number';
|
|
168
|
-
case ns.w3.xmlSchema.boolean:
|
|
169
|
-
case ns.aml.vocabularies.shapes.boolean:
|
|
170
|
-
return 'boolean';
|
|
171
|
-
case ns.aml.vocabularies.shapes.nil:
|
|
172
|
-
case ns.w3.xmlSchema.nil:
|
|
173
|
-
return 'null';
|
|
174
|
-
default:
|
|
175
|
-
return 'string';
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
nodeShapeRangeToPropertySchema(schema) {
|
|
179
|
-
const { description, name, displayName, id, readOnly, writeOnly, closed, minProperties, maxProperties } = schema;
|
|
180
|
-
const properties = collectNodeProperties(schema);
|
|
181
|
-
const result = {
|
|
182
|
-
$id: id,
|
|
183
|
-
type: 'object',
|
|
184
|
-
title: cleanName(displayName || name),
|
|
185
|
-
properties: {},
|
|
186
|
-
required: [],
|
|
187
|
-
};
|
|
188
|
-
if (description) {
|
|
189
|
-
result.description = description;
|
|
190
|
-
}
|
|
191
|
-
if (typeof readOnly === 'boolean') {
|
|
192
|
-
result.readOnly = readOnly;
|
|
193
|
-
}
|
|
194
|
-
if (typeof writeOnly === 'boolean') {
|
|
195
|
-
result.writeOnly = writeOnly;
|
|
196
|
-
}
|
|
197
|
-
if (typeof closed === 'boolean') {
|
|
198
|
-
result.additionalProperties = !closed;
|
|
199
|
-
}
|
|
200
|
-
if (typeof minProperties === 'number') {
|
|
201
|
-
result.minProperties = minProperties;
|
|
202
|
-
}
|
|
203
|
-
if (typeof maxProperties === 'number') {
|
|
204
|
-
result.maxProperties = maxProperties;
|
|
205
|
-
}
|
|
206
|
-
properties.forEach((property) => this.appendSchemaProperty(result, property));
|
|
207
|
-
return result;
|
|
208
|
-
}
|
|
209
|
-
arrayShapeRangeToPropertySchema(schema) {
|
|
210
|
-
const { description, name, displayName, id, readOnly, writeOnly, items, minItems, maxItems, uniqueItems } = schema;
|
|
211
|
-
const result = {
|
|
212
|
-
$id: id,
|
|
213
|
-
type: 'array',
|
|
214
|
-
title: cleanName(displayName || name),
|
|
215
|
-
items: {
|
|
216
|
-
anyOf: [],
|
|
217
|
-
},
|
|
218
|
-
required: [],
|
|
219
|
-
additionalItems: false,
|
|
220
|
-
};
|
|
221
|
-
if (description) {
|
|
222
|
-
result.description = description;
|
|
223
|
-
}
|
|
224
|
-
if (typeof readOnly === 'boolean') {
|
|
225
|
-
result.readOnly = readOnly;
|
|
226
|
-
}
|
|
227
|
-
if (typeof writeOnly === 'boolean') {
|
|
228
|
-
result.writeOnly = writeOnly;
|
|
229
|
-
}
|
|
230
|
-
if (typeof uniqueItems === 'boolean') {
|
|
231
|
-
result.uniqueItems = uniqueItems;
|
|
232
|
-
}
|
|
233
|
-
if (items) {
|
|
234
|
-
const value = this.rangeToPropertySchema(items);
|
|
235
|
-
if (value) {
|
|
236
|
-
result.items.anyOf.push(value);
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
if (typeof minItems === 'number') {
|
|
240
|
-
result.minItems = minItems;
|
|
241
|
-
}
|
|
242
|
-
if (typeof maxItems === 'number') {
|
|
243
|
-
result.maxItems = maxItems;
|
|
244
|
-
}
|
|
245
|
-
return result;
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
//# sourceMappingURL=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S,CAAA;QAC9B,CAAC;QACD,IAAI,OAAO,WAAW,KAAK,SAAS,EAAE,CAAC;YACrC,MAAM,CAAC,WAAW,GAAG,WAAW,CAAA;QAClC,CAAC;QACD,IAAI,KAAK,EAAE,CAAC;YACV,MAAM,KAAK,GAAG,IAAI,CAAC,qBAAqB,CAAC,KAAK,CAAC,CAAA;YAC/C,IAAI,KAAK,EAAE,CAAC;gBACV,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;YAChC,CAAC;QACH,CAAC;QACD,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE,CAAC;YACjC,MAAM,CAAC,QAAQ,GAAG,QAAQ,CAAA;QAC5B,CAAC;QACD,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE,CAAC;YACjC,MAAM,CAAC,QAAQ,GAAG,QAAQ,CAAA;QAC5B,CAAC;QACD,OAAO,MAAM,CAAA;IACf,CAAC;CACF","sourcesContent":["import { AmfNamespace as ns } from './definitions/Namespace.js'\nimport {\n IApiArrayShape,\n IApiNodeShape,\n IApiPropertyShape,\n IApiScalarNode,\n IApiScalarShape,\n IShapeUnion,\n} from './definitions/Shapes.js'\nimport { collectNodeProperties } from './Utils.js'\n\nexport interface IMonacoSchema {\n uri: string\n schema: IMonacoProperty\n fileMatch?: string[]\n}\n\nexport interface IMonacoProperty {\n $id?: string\n title: string\n type: string\n description?: string\n readOnly?: boolean\n writeOnly?: boolean\n}\n\nexport interface IMonacoScalarProperty extends IMonacoProperty {\n default?: string\n pattern?: string\n format?: string\n exclusiveMaximum?: boolean\n exclusiveMinimum?: boolean\n maxLength?: number\n minLength?: number\n minimum?: number\n maximum?: number\n multipleOf?: number\n enum?: string[]\n}\n\nexport interface IMonacoObjectProperty extends IMonacoProperty {\n properties: Record<string, IMonacoProperty>\n required: string[]\n additionalProperties?: boolean\n minProperties?: number\n maxProperties?: number\n}\n\nexport interface IMonacoArrayProperty extends IMonacoProperty {\n additionalItems?: boolean\n items: {\n anyOf: IMonacoProperty[]\n }\n uniqueItems?: boolean\n minItems?: number\n maxItems?: number\n required: string[]\n}\n\nfunction cleanName(name?: string): string {\n if (!name) {\n return ''\n }\n return name.replace('?', '')\n}\n\n/**\n * A class to generate JSON schema from an ApiShapeUnion declaration to use with the Monaco editor schemas.\n */\nexport class ApiMonacoSchemaGenerator {\n schemas: IMonacoSchema[] = []\n\n /**\n * @param parentUri The URI for the fileMatch property.\n */\n generate(schema: IShapeUnion, parentUri: string): IMonacoSchema[] {\n this.schemas = []\n if (!schema) {\n return []\n }\n const { types } = schema\n if (types.includes(ns.w3.shacl.NodeShape)) {\n return this.fromNodeShape(schema as IApiNodeShape, parentUri)\n }\n return []\n }\n\n /**\n * @param parentUri The URI for the fileMatch property.\n */\n fromNodeShape(schema: IApiNodeShape, parentUri?: string): IMonacoSchema[] {\n const { id, name } = schema\n const properties = collectNodeProperties(schema)\n const content: IMonacoObjectProperty = {\n title: cleanName(name),\n type: 'object',\n properties: {},\n required: [],\n }\n const result: IMonacoSchema = {\n uri: id,\n schema: content,\n }\n if (parentUri) {\n result.fileMatch = [parentUri]\n }\n this.schemas.push(result)\n if (!Array.isArray(properties) || !properties.length) {\n return this.schemas\n }\n properties.forEach((property) => this.appendSchemaProperty(content, property))\n return this.schemas\n }\n\n appendSchemaProperty(content: IMonacoObjectProperty, property: IApiPropertyShape): void {\n const { name, range, minCount } = property\n if (!range) {\n return\n }\n const value = this.rangeToPropertySchema(range)\n if (value && name) {\n content.properties[name] = value\n if (minCount === 1) {\n content.required.push(name)\n }\n }\n }\n\n rangeToPropertySchema(\n range: IShapeUnion\n ): IMonacoScalarProperty | IMonacoObjectProperty | IMonacoArrayProperty | undefined {\n const { types } = range\n if (types.includes(ns.aml.vocabularies.shapes.ScalarShape)) {\n return this.scalarRangeToPropertySchema(range as IApiScalarShape)\n }\n if (types.includes(ns.w3.shacl.NodeShape)) {\n return this.nodeShapeRangeToPropertySchema(range as IApiNodeShape)\n }\n if (types.includes(ns.aml.vocabularies.shapes.ArrayShape)) {\n return this.arrayShapeRangeToPropertySchema(range as IApiArrayShape)\n }\n return undefined\n }\n\n scalarRangeToPropertySchema(schema: IApiScalarShape): IMonacoScalarProperty {\n const {\n values,\n description,\n name,\n displayName,\n defaultValueStr,\n exclusiveMaximum,\n exclusiveMinimum,\n minimum,\n maximum,\n minLength,\n maxLength,\n id,\n multipleOf,\n pattern,\n readOnly,\n writeOnly,\n } = schema\n const type = this.schemaTypeToJsonDataType(schema.dataType)\n const result: IMonacoScalarProperty = {\n $id: id,\n type,\n title: cleanName(displayName || name),\n }\n if (description) {\n result.description = description\n }\n if (defaultValueStr) {\n result.default = defaultValueStr\n }\n if (typeof exclusiveMaximum === 'boolean') {\n result.exclusiveMaximum = exclusiveMaximum\n }\n if (typeof exclusiveMinimum === 'boolean') {\n result.exclusiveMinimum = exclusiveMinimum\n }\n if (typeof maxLength === 'number') {\n result.maxLength = maxLength\n }\n if (typeof minLength === 'number') {\n result.minLength = minLength\n }\n if (typeof minimum === 'number') {\n result.minimum = minimum\n }\n if (typeof maximum === 'number') {\n result.maximum = maximum\n }\n if (typeof multipleOf === 'number') {\n result.multipleOf = multipleOf\n }\n if (typeof pattern === 'string') {\n result.pattern = pattern\n }\n if (typeof readOnly === 'boolean') {\n result.readOnly = readOnly\n }\n if (typeof writeOnly === 'boolean') {\n result.writeOnly = writeOnly\n }\n switch (schema.dataType) {\n case ns.aml.vocabularies.shapes.dateTimeOnly:\n result.format = 'date-time'\n break\n case ns.w3.xmlSchema.date:\n result.format = 'date'\n break\n case ns.w3.xmlSchema.time:\n result.format = 'time'\n break\n default:\n }\n if (Array.isArray(values) && values.length) {\n // enum properties\n result.enum = []\n values.forEach((value) => {\n const { types } = value\n if (types.includes(ns.aml.vocabularies.data.Scalar)) {\n const typed = value as IApiScalarNode\n if (typed.value) {\n ;(result.enum as string[]).push(typed.value)\n }\n }\n })\n }\n return result\n }\n\n /**\n * Translates AMF data type to JSON schema data type.\n */\n schemaTypeToJsonDataType(schemaType?: string): string {\n switch (schemaType) {\n case ns.aml.vocabularies.shapes.number:\n case ns.aml.vocabularies.shapes.integer:\n case ns.aml.vocabularies.shapes.float:\n case ns.aml.vocabularies.shapes.long:\n case ns.aml.vocabularies.shapes.double:\n case ns.w3.xmlSchema.number:\n case ns.w3.xmlSchema.integer:\n case ns.w3.xmlSchema.float:\n case ns.w3.xmlSchema.long:\n case ns.w3.xmlSchema.double:\n return 'number'\n case ns.w3.xmlSchema.boolean:\n case ns.aml.vocabularies.shapes.boolean:\n return 'boolean'\n case ns.aml.vocabularies.shapes.nil:\n case ns.w3.xmlSchema.nil:\n return 'null'\n default:\n return 'string'\n }\n }\n\n nodeShapeRangeToPropertySchema(schema: IApiNodeShape): IMonacoObjectProperty {\n const { description, name, displayName, id, readOnly, writeOnly, closed, minProperties, maxProperties } = schema\n const properties = collectNodeProperties(schema)\n\n const result: IMonacoObjectProperty = {\n $id: id,\n type: 'object',\n title: cleanName(displayName || name),\n properties: {},\n required: [],\n }\n if (description) {\n result.description = description\n }\n if (typeof readOnly === 'boolean') {\n result.readOnly = readOnly\n }\n if (typeof writeOnly === 'boolean') {\n result.writeOnly = writeOnly\n }\n if (typeof closed === 'boolean') {\n result.additionalProperties = !closed\n }\n if (typeof minProperties === 'number') {\n result.minProperties = minProperties\n }\n if (typeof maxProperties === 'number') {\n result.maxProperties = maxProperties\n }\n properties.forEach((property) => this.appendSchemaProperty(result, property))\n return result\n }\n\n arrayShapeRangeToPropertySchema(schema: IApiArrayShape): IMonacoArrayProperty {\n const { description, name, displayName, id, readOnly, writeOnly, items, minItems, maxItems, uniqueItems } = schema\n const result: IMonacoArrayProperty = {\n $id: id,\n type: 'array',\n title: cleanName(displayName || name),\n items: {\n anyOf: [],\n },\n required: [],\n additionalItems: false,\n }\n if (description) {\n result.description = description\n }\n if (typeof readOnly === 'boolean') {\n result.readOnly = readOnly\n }\n if (typeof writeOnly === 'boolean') {\n result.writeOnly = writeOnly\n }\n if (typeof uniqueItems === 'boolean') {\n result.uniqueItems = uniqueItems\n }\n if (items) {\n const value = this.rangeToPropertySchema(items)\n if (value) {\n result.items.anyOf.push(value)\n }\n }\n if (typeof minItems === 'number') {\n result.minItems = minItems\n }\n if (typeof maxItems === 'number') {\n result.maxItems = maxItems\n }\n return result\n }\n}\n"]}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { IApiDataExample, IApiPropertyShape, IShapeUnion } from './definitions/Shapes.js';
|
|
2
|
-
import { ShapeBase, IShapeRenderOptions } from './shape/ShapeBase.js';
|
|
3
|
-
export interface ISchemaExample extends IApiDataExample {
|
|
4
|
-
/**
|
|
5
|
-
* The value to render as the example value.
|
|
6
|
-
*/
|
|
7
|
-
renderValue?: string | number | boolean | null | undefined;
|
|
8
|
-
label?: string;
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* A class that processes AMF's Shape to auto-generate a schema from examples/type for a given media type.
|
|
12
|
-
* This should be used when examples for the Shape are not available but the application still needs to
|
|
13
|
-
* render an example or a schema from the Shape.
|
|
14
|
-
* If examples can be found directly in the shape, use the `ApiExampleGenerator` instead.
|
|
15
|
-
*/
|
|
16
|
-
export declare class ApiSchemaGenerator {
|
|
17
|
-
mime: string;
|
|
18
|
-
opts: Readonly<IShapeRenderOptions>;
|
|
19
|
-
generator?: ShapeBase;
|
|
20
|
-
/**
|
|
21
|
-
*
|
|
22
|
-
* @param mime The example mime type to format the generated example.
|
|
23
|
-
* @param opts Optional configuration.
|
|
24
|
-
*/
|
|
25
|
-
constructor(mime: string, opts?: IShapeRenderOptions);
|
|
26
|
-
/**
|
|
27
|
-
* @param shape The Shape definition
|
|
28
|
-
* @param mime The mime type for the value.
|
|
29
|
-
* @returns Customized Example with the `renderValue` that is the generated Example value.
|
|
30
|
-
*/
|
|
31
|
-
static asExample(shape: IShapeUnion, mime: string, opts?: IShapeRenderOptions): ISchemaExample | undefined;
|
|
32
|
-
/**
|
|
33
|
-
* @param shape The Shape definition
|
|
34
|
-
* @param mime The mime type for the value.
|
|
35
|
-
* @returns The generated schema
|
|
36
|
-
*/
|
|
37
|
-
static asSchema(shape: IShapeUnion, mime: string, opts?: IShapeRenderOptions): string | number | boolean | null | undefined;
|
|
38
|
-
/**
|
|
39
|
-
* Generates the schema from the AMF shape.
|
|
40
|
-
*
|
|
41
|
-
* @param shape The Shape definition
|
|
42
|
-
*/
|
|
43
|
-
generate(shape: IShapeUnion | IApiPropertyShape<IShapeUnion>): string | number | boolean | null | undefined;
|
|
44
|
-
/**
|
|
45
|
-
* @link {#generate()}
|
|
46
|
-
* @param shape The Shape definition
|
|
47
|
-
*/
|
|
48
|
-
toValue(shape: IShapeUnion): string | number | boolean | null | undefined;
|
|
49
|
-
/**
|
|
50
|
-
* Generates an API Example object with the value to render.
|
|
51
|
-
* @param shape The Shape definition
|
|
52
|
-
* @returns Customized Example with the `renderValue` that is the generated Example value.
|
|
53
|
-
*/
|
|
54
|
-
toExample(shape: IShapeUnion): ISchemaExample | undefined;
|
|
55
|
-
}
|
|
56
|
-
//# sourceMappingURL=ApiSchemaGenerator.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ApiSchemaGenerator.d.ts","sourceRoot":"","sources":["../../../src/amf/ApiSchemaGenerator.ts"],"names":[],"mappings":"AACA,OAAO,EAAgB,eAAe,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AACvG,OAAO,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAA;AAIrE,MAAM,WAAW,cAAe,SAAQ,eAAe;IACrD;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,SAAS,CAAA;IAC1D,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED;;;;;GAKG;AACH,qBAAa,kBAAkB;IAWpB,IAAI,EAAE,MAAM;IAVrB,IAAI,EAAE,QAAQ,CAAC,mBAAm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