@api-client/core 0.19.10 → 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/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/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/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/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/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 -1
- package/package.json +11 -14
- package/src/events/EventTypes.ts +0 -2
- package/src/events/Events.ts +0 -2
- 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/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/models/http-flows/LegacyTranslator.ts +1 -1
- package/src/runtime/http-runner/HttpFlows.ts +1 -1
- 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/domain_asociation.spec.ts +13 -13
- 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/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
package/src/amf/AmfSerializer.ts
DELETED
|
@@ -1,2358 +0,0 @@
|
|
|
1
|
-
import { AmfMixin, findAmfType, getArrayItems } from './AmfMixin.js'
|
|
2
|
-
import {
|
|
3
|
-
IAmfAnyShape,
|
|
4
|
-
IAmfApi,
|
|
5
|
-
IAmfArrayNode,
|
|
6
|
-
IAmfArrayShape,
|
|
7
|
-
IAmfAsyncApi,
|
|
8
|
-
IAmfCreativeWork,
|
|
9
|
-
IAmfDataArrangeShape,
|
|
10
|
-
IAmfDataNode,
|
|
11
|
-
IAmfDocumentSourceMaps,
|
|
12
|
-
IAmfDomainElement,
|
|
13
|
-
IAmfEndPoint,
|
|
14
|
-
IAmfExample,
|
|
15
|
-
IAmfFileShape,
|
|
16
|
-
IAmfLicense,
|
|
17
|
-
IAmfNodeShape,
|
|
18
|
-
IAmfObjectNode,
|
|
19
|
-
IAmfOperation,
|
|
20
|
-
IAmfOrganization,
|
|
21
|
-
IAmfParameter,
|
|
22
|
-
IAmfPropertyShape,
|
|
23
|
-
IAmfRecursiveShape,
|
|
24
|
-
IAmfScalarNode,
|
|
25
|
-
IAmfScalarShape,
|
|
26
|
-
IAmfSchemaShape,
|
|
27
|
-
IAmfSecurityRequirement,
|
|
28
|
-
IAmfServer,
|
|
29
|
-
IAmfShape,
|
|
30
|
-
IAmfSynthesizedField,
|
|
31
|
-
IAmfTupleShape,
|
|
32
|
-
IAmfUnionShape,
|
|
33
|
-
IAmfWebApi,
|
|
34
|
-
IAmfXMLSerializer,
|
|
35
|
-
IAmfPayload,
|
|
36
|
-
IAmfTag,
|
|
37
|
-
IAmfCallback,
|
|
38
|
-
IAmfRequest,
|
|
39
|
-
IAmfResponse,
|
|
40
|
-
IAmfTemplatedLink,
|
|
41
|
-
IAmfIriTemplateMapping,
|
|
42
|
-
IAmfParametrizedSecurityScheme,
|
|
43
|
-
IAmfSecurityScheme,
|
|
44
|
-
IAmfSettings,
|
|
45
|
-
IAmfOAuth1Settings,
|
|
46
|
-
IAmfOAuth2Settings,
|
|
47
|
-
IAmfApiKeySettings,
|
|
48
|
-
IAmfHttpSettings,
|
|
49
|
-
IAmfOpenIdConnectSettings,
|
|
50
|
-
IAmfOAuth2Flow,
|
|
51
|
-
IAmfScope,
|
|
52
|
-
IAmfParametrizedDeclaration,
|
|
53
|
-
IAmfParametrizedTrait,
|
|
54
|
-
IAmfParametrizedResourceType,
|
|
55
|
-
IAmfVariableValue,
|
|
56
|
-
IAmfAbstractDeclaration,
|
|
57
|
-
} from './definitions/Amf.js'
|
|
58
|
-
import {
|
|
59
|
-
IApiAbstractDeclaration,
|
|
60
|
-
IApiAsync,
|
|
61
|
-
IApiBase,
|
|
62
|
-
IApiCallback,
|
|
63
|
-
IApiDocumentation,
|
|
64
|
-
IApiDocumentSourceMaps,
|
|
65
|
-
IApiEndPoint,
|
|
66
|
-
IApiEndPointWithOperationsListItem,
|
|
67
|
-
IApiIriTemplateMapping,
|
|
68
|
-
IApiLicense,
|
|
69
|
-
IApiOperation,
|
|
70
|
-
IApiOperationListItem,
|
|
71
|
-
IApiOrganization,
|
|
72
|
-
IApiParameter,
|
|
73
|
-
IApiParametrizedDeclaration,
|
|
74
|
-
IApiParametrizedResourceType,
|
|
75
|
-
IApiParametrizedSecurityScheme,
|
|
76
|
-
IApiParametrizedTrait,
|
|
77
|
-
IApiPayload,
|
|
78
|
-
IApiRequest,
|
|
79
|
-
IApiResponse,
|
|
80
|
-
IApiSecurityApiKeySettings,
|
|
81
|
-
IApiSecurityHttpSettings,
|
|
82
|
-
IApiSecurityOAuth1Settings,
|
|
83
|
-
IApiSecurityOAuth2Flow,
|
|
84
|
-
IApiSecurityOAuth2Settings,
|
|
85
|
-
IApiSecurityOpenIdConnectSettings,
|
|
86
|
-
IApiSecurityRequirement,
|
|
87
|
-
IApiSecurityScheme,
|
|
88
|
-
IApiSecuritySchemeListItem,
|
|
89
|
-
IApiSecurityScope,
|
|
90
|
-
IApiSecuritySettings,
|
|
91
|
-
IApiSecuritySettingsUnion,
|
|
92
|
-
IApiServer,
|
|
93
|
-
IApiSummary,
|
|
94
|
-
IApiSynthesizedField,
|
|
95
|
-
IApiTag,
|
|
96
|
-
IApiTemplatedLink,
|
|
97
|
-
IApiVariableValue,
|
|
98
|
-
IApiWeb,
|
|
99
|
-
IShapeProcessingOptions,
|
|
100
|
-
} from './definitions/Api.js'
|
|
101
|
-
import { IApiCustomDomainProperty } from './definitions/Base.js'
|
|
102
|
-
import { AmfNamespace as ns } from './definitions/Namespace.js'
|
|
103
|
-
import {
|
|
104
|
-
IApiAnyShape,
|
|
105
|
-
IApiArrayNode,
|
|
106
|
-
IApiArrayShape,
|
|
107
|
-
IApiDataArrangeShape,
|
|
108
|
-
IApiDataExample,
|
|
109
|
-
IApiDataNode,
|
|
110
|
-
IApiDataNodeUnion,
|
|
111
|
-
IApiFileShape,
|
|
112
|
-
IApiNodeShape,
|
|
113
|
-
IApiObjectNode,
|
|
114
|
-
IApiPropertyShape,
|
|
115
|
-
IApiRecursiveShape,
|
|
116
|
-
IApiScalarNode,
|
|
117
|
-
IApiScalarShape,
|
|
118
|
-
IApiSchemaShape,
|
|
119
|
-
IApiShape,
|
|
120
|
-
IShapeUnion,
|
|
121
|
-
IApiTupleShape,
|
|
122
|
-
IApiUnionShape,
|
|
123
|
-
IApiXmlSerializer,
|
|
124
|
-
} from './definitions/Shapes.js'
|
|
125
|
-
|
|
126
|
-
/**
|
|
127
|
-
* A class that takes AMF's ld+json model and outputs JavaScript interface of it.
|
|
128
|
-
*/
|
|
129
|
-
export class AmfSerializer extends AmfMixin(Object) {
|
|
130
|
-
/**
|
|
131
|
-
* @param graph Optional AMF generated graph model.
|
|
132
|
-
*/
|
|
133
|
-
constructor(graph?: IAmfDomainElement) {
|
|
134
|
-
super()
|
|
135
|
-
if (graph) {
|
|
136
|
-
this.amf = graph
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
* @param types The list of graph object types. When not defined it returns an empty array.
|
|
142
|
-
* @returns The expanded types.
|
|
143
|
-
*/
|
|
144
|
-
readTypes(types: string[], context?: Record<string, string>): string[] {
|
|
145
|
-
let target = types
|
|
146
|
-
if (typeof target === 'string') {
|
|
147
|
-
target = [target]
|
|
148
|
-
}
|
|
149
|
-
if (!Array.isArray(target)) {
|
|
150
|
-
return []
|
|
151
|
-
}
|
|
152
|
-
return target.map((type) => this._expandKey(type, context))
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
/**
|
|
156
|
-
* @param object The API to serialize.
|
|
157
|
-
* @returns API summary, without complex objects.
|
|
158
|
-
*/
|
|
159
|
-
apiSummary(object: IAmfApi): IApiSummary {
|
|
160
|
-
const context = object['@context']
|
|
161
|
-
const result: IApiSummary = {
|
|
162
|
-
id: object['@id'],
|
|
163
|
-
types: this.readTypes(object['@type'], context),
|
|
164
|
-
customDomainProperties: this.customDomainProperties(object, context),
|
|
165
|
-
sourceMaps: this.sourceMap(object),
|
|
166
|
-
schemes: [],
|
|
167
|
-
accepts: [],
|
|
168
|
-
contentType: [],
|
|
169
|
-
documentations: [],
|
|
170
|
-
tags: [],
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
const name = this._getValue(object, ns.aml.vocabularies.core.name, context)
|
|
174
|
-
if (name && typeof name === 'string') {
|
|
175
|
-
result.name = name
|
|
176
|
-
}
|
|
177
|
-
const description = this._getValue(object, ns.aml.vocabularies.core.description, context)
|
|
178
|
-
if (description && typeof description === 'string') {
|
|
179
|
-
result.description = description
|
|
180
|
-
}
|
|
181
|
-
const version = this._getValue(object, ns.aml.vocabularies.core.version, context)
|
|
182
|
-
if (version && typeof version === 'string') {
|
|
183
|
-
result.version = version
|
|
184
|
-
}
|
|
185
|
-
const termsOfService = this._getValue(object, ns.aml.vocabularies.core.termsOfService, context)
|
|
186
|
-
if (termsOfService && typeof termsOfService === 'string') {
|
|
187
|
-
result.termsOfService = termsOfService
|
|
188
|
-
}
|
|
189
|
-
const accepts = object[
|
|
190
|
-
this._getAmfKey(ns.aml.vocabularies.apiContract.accepts, context) as keyof IAmfApi
|
|
191
|
-
] as unknown[]
|
|
192
|
-
if (Array.isArray(accepts) && accepts.length) {
|
|
193
|
-
result.accepts = this._getValueArray(object, ns.aml.vocabularies.apiContract.accepts, context) as string[]
|
|
194
|
-
}
|
|
195
|
-
const contentType = object[this._getAmfKey(ns.aml.vocabularies.apiContract.contentType, context) as keyof IAmfApi]
|
|
196
|
-
if (Array.isArray(contentType) && contentType.length) {
|
|
197
|
-
result.contentType = this._getValueArray(object, ns.aml.vocabularies.apiContract.contentType, context) as string[]
|
|
198
|
-
}
|
|
199
|
-
const schemes = object[this._getAmfKey(ns.aml.vocabularies.apiContract.scheme, context) as keyof IAmfApi]
|
|
200
|
-
if (Array.isArray(schemes) && schemes.length) {
|
|
201
|
-
result.schemes = this._getValueArray(object, ns.aml.vocabularies.apiContract.scheme, context) as string[]
|
|
202
|
-
}
|
|
203
|
-
let provider = object[this._getAmfKey(ns.aml.vocabularies.core.provider, context) as keyof IAmfApi] as
|
|
204
|
-
| IAmfOrganization[]
|
|
205
|
-
| IAmfOrganization
|
|
206
|
-
if (Array.isArray(provider)) {
|
|
207
|
-
;[provider] = provider
|
|
208
|
-
}
|
|
209
|
-
if (provider) {
|
|
210
|
-
result.provider = this.provider(provider)
|
|
211
|
-
}
|
|
212
|
-
let license = object[this._getAmfKey(ns.aml.vocabularies.core.license, context) as keyof IAmfApi] as
|
|
213
|
-
| IAmfLicense
|
|
214
|
-
| IAmfLicense[]
|
|
215
|
-
if (Array.isArray(license)) {
|
|
216
|
-
;[license] = license
|
|
217
|
-
}
|
|
218
|
-
if (license) {
|
|
219
|
-
result.license = this.license(license)
|
|
220
|
-
}
|
|
221
|
-
const tags = object[this._getAmfKey(ns.aml.vocabularies.apiContract.tag, context) as keyof IAmfApi] as
|
|
222
|
-
| IAmfTag[]
|
|
223
|
-
| undefined
|
|
224
|
-
if (Array.isArray(tags) && tags.length) {
|
|
225
|
-
result.tags = tags.map((t) => this.tag(t))
|
|
226
|
-
}
|
|
227
|
-
const docs = object[this._getAmfKey(ns.aml.vocabularies.core.documentation, context) as keyof IAmfApi] as
|
|
228
|
-
| IAmfCreativeWork[]
|
|
229
|
-
| undefined
|
|
230
|
-
if (Array.isArray(docs) && docs.length) {
|
|
231
|
-
result.documentations = docs.map((d) => this.documentation(d))
|
|
232
|
-
}
|
|
233
|
-
return result
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
api(object: IAmfApi, context?: Record<string, string>): IApiBase {
|
|
237
|
-
const objectContext = context || object['@context']
|
|
238
|
-
const result = this.apiSummary(object) as IApiBase
|
|
239
|
-
result.endPoints = []
|
|
240
|
-
result.servers = []
|
|
241
|
-
result.security = []
|
|
242
|
-
|
|
243
|
-
const endPoints = object[
|
|
244
|
-
this._getAmfKey(ns.aml.vocabularies.apiContract.endpoint, objectContext) as keyof IAmfApi
|
|
245
|
-
] as IAmfEndPoint[] | undefined
|
|
246
|
-
if (Array.isArray(endPoints) && endPoints.length) {
|
|
247
|
-
result.endPoints = endPoints.map((e) => this.endPoint(e, objectContext))
|
|
248
|
-
}
|
|
249
|
-
const servers = object[this._getAmfKey(ns.aml.vocabularies.apiContract.server, objectContext) as keyof IAmfApi] as
|
|
250
|
-
| IAmfServer
|
|
251
|
-
| IAmfServer[]
|
|
252
|
-
| undefined
|
|
253
|
-
if (Array.isArray(servers) && servers.length) {
|
|
254
|
-
result.servers = servers.map((s) => this.server(s, objectContext))
|
|
255
|
-
}
|
|
256
|
-
const security = object[this._getAmfKey(ns.aml.vocabularies.security.security, objectContext) as keyof IAmfApi] as
|
|
257
|
-
| IAmfSecurityRequirement[]
|
|
258
|
-
| undefined
|
|
259
|
-
if (Array.isArray(security) && security.length) {
|
|
260
|
-
result.security = security.map((s) => this.securityRequirement(s, objectContext))
|
|
261
|
-
}
|
|
262
|
-
return result
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
webApi(object: IAmfWebApi, context?: Record<string, string>): IApiWeb {
|
|
266
|
-
return this.api(object, context)
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
asyncApi(object: IAmfAsyncApi, context?: Record<string, string>): IApiAsync {
|
|
270
|
-
return this.api(object, context)
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
provider(object: IAmfOrganization, context?: Record<string, string>): IApiOrganization {
|
|
274
|
-
const objectContext = context || object['@context']
|
|
275
|
-
const result: IApiOrganization = {
|
|
276
|
-
id: object['@id'],
|
|
277
|
-
types: this.readTypes(object['@type'], objectContext),
|
|
278
|
-
customDomainProperties: this.customDomainProperties(object, objectContext),
|
|
279
|
-
sourceMaps: this.sourceMap(object, objectContext),
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
const name = this._getValue(object, ns.aml.vocabularies.core.name, objectContext)
|
|
283
|
-
if (name && typeof name === 'string') {
|
|
284
|
-
result.name = name
|
|
285
|
-
}
|
|
286
|
-
const url = this._getLinkValue(object, ns.aml.vocabularies.core.url, objectContext)
|
|
287
|
-
if (url && typeof url === 'string') {
|
|
288
|
-
result.url = url
|
|
289
|
-
}
|
|
290
|
-
const email = this._getValue(object, ns.aml.vocabularies.core.email, objectContext)
|
|
291
|
-
if (email && typeof email === 'string') {
|
|
292
|
-
result.email = email
|
|
293
|
-
}
|
|
294
|
-
return result
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
license(object: IAmfLicense, context?: Record<string, string>): IApiLicense {
|
|
298
|
-
const objectContext = context || object['@context']
|
|
299
|
-
const result: IApiLicense = {
|
|
300
|
-
id: object['@id'],
|
|
301
|
-
types: this.readTypes(object['@type'], objectContext),
|
|
302
|
-
customDomainProperties: this.customDomainProperties(object, objectContext),
|
|
303
|
-
sourceMaps: this.sourceMap(object, objectContext),
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
const name = this._getValue(object, ns.aml.vocabularies.core.name, objectContext)
|
|
307
|
-
if (name && typeof name === 'string') {
|
|
308
|
-
result.name = name
|
|
309
|
-
}
|
|
310
|
-
const url = this._getLinkValue(object, ns.aml.vocabularies.core.url, objectContext)
|
|
311
|
-
if (url && typeof url === 'string') {
|
|
312
|
-
result.url = url
|
|
313
|
-
}
|
|
314
|
-
return result
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
/**
|
|
318
|
-
* @param object The AMF Server to serialize.
|
|
319
|
-
* @returns Serialized Server
|
|
320
|
-
*/
|
|
321
|
-
server(object: IAmfServer, context?: Record<string, string>): IApiServer {
|
|
322
|
-
const objectContext = context || object['@context']
|
|
323
|
-
|
|
324
|
-
const url = (this._getValue(object, ns.aml.vocabularies.core.urlTemplate, objectContext) as string) || ''
|
|
325
|
-
const result: IApiServer = {
|
|
326
|
-
id: object['@id'],
|
|
327
|
-
types: this.readTypes(object['@type'], objectContext),
|
|
328
|
-
url,
|
|
329
|
-
variables: [],
|
|
330
|
-
customDomainProperties: this.customDomainProperties(object, objectContext),
|
|
331
|
-
sourceMaps: this.sourceMap(object, objectContext),
|
|
332
|
-
}
|
|
333
|
-
const description = this._getValue(object, ns.aml.vocabularies.core.description, objectContext)
|
|
334
|
-
if (description && typeof description === 'string') {
|
|
335
|
-
result.description = description
|
|
336
|
-
}
|
|
337
|
-
const variables = object[
|
|
338
|
-
this._getAmfKey(ns.aml.vocabularies.apiContract.variable, objectContext) as keyof IAmfServer
|
|
339
|
-
] as IAmfParameter[]
|
|
340
|
-
if (Array.isArray(variables) && variables.length) {
|
|
341
|
-
result.variables = variables.map((p) => this.parameter(p, objectContext))
|
|
342
|
-
}
|
|
343
|
-
const protocol = this._getValue(object, ns.aml.vocabularies.apiContract.protocol, objectContext) as string
|
|
344
|
-
const protocolVersion = this._getValue(
|
|
345
|
-
object,
|
|
346
|
-
ns.aml.vocabularies.apiContract.protocolVersion,
|
|
347
|
-
objectContext
|
|
348
|
-
) as string
|
|
349
|
-
if (protocol) {
|
|
350
|
-
result.protocol = protocol
|
|
351
|
-
}
|
|
352
|
-
if (protocolVersion) {
|
|
353
|
-
result.protocolVersion = protocolVersion
|
|
354
|
-
}
|
|
355
|
-
const security = object[
|
|
356
|
-
this._getAmfKey(ns.aml.vocabularies.security.security, objectContext) as keyof IAmfServer
|
|
357
|
-
] as IAmfSecurityRequirement[]
|
|
358
|
-
if (Array.isArray(security) && security.length) {
|
|
359
|
-
result.security = security.map((p) => this.securityRequirement(p, objectContext))
|
|
360
|
-
}
|
|
361
|
-
return result
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
/**
|
|
365
|
-
* @param object The Parameter to serialize.
|
|
366
|
-
* @returns Serialized Parameter
|
|
367
|
-
*/
|
|
368
|
-
parameter(object: IAmfParameter, context?: Record<string, string>): IApiParameter {
|
|
369
|
-
const objectContext = context || object['@context']
|
|
370
|
-
const result: IApiParameter = {
|
|
371
|
-
id: object['@id'],
|
|
372
|
-
types: this.readTypes(object['@type'], objectContext),
|
|
373
|
-
payloads: [],
|
|
374
|
-
examples: [],
|
|
375
|
-
customDomainProperties: this.customDomainProperties(object, objectContext),
|
|
376
|
-
sourceMaps: this.sourceMap(object, objectContext),
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
const name = this._getValue(object, ns.aml.vocabularies.core.name, objectContext)
|
|
380
|
-
if (name && typeof name === 'string') {
|
|
381
|
-
result.name = name
|
|
382
|
-
}
|
|
383
|
-
const paramName = this._getValue(object, ns.aml.vocabularies.apiContract.paramName, objectContext)
|
|
384
|
-
if (paramName && typeof paramName === 'string') {
|
|
385
|
-
result.paramName = paramName
|
|
386
|
-
}
|
|
387
|
-
const description = this._getValue(object, ns.aml.vocabularies.core.description, objectContext)
|
|
388
|
-
if (description && typeof description === 'string') {
|
|
389
|
-
result.description = description
|
|
390
|
-
}
|
|
391
|
-
const required = this._getValue(object, ns.aml.vocabularies.apiContract.required, objectContext)
|
|
392
|
-
if (typeof required === 'boolean') {
|
|
393
|
-
result.required = required
|
|
394
|
-
}
|
|
395
|
-
const allowEmptyValue = this._getValue(object, ns.aml.vocabularies.apiContract.allowEmptyValue, objectContext)
|
|
396
|
-
if (typeof allowEmptyValue === 'boolean') {
|
|
397
|
-
result.allowEmptyValue = allowEmptyValue
|
|
398
|
-
}
|
|
399
|
-
const deprecated = this._getValue(object, ns.aml.vocabularies.document.deprecated, objectContext)
|
|
400
|
-
if (typeof deprecated === 'boolean') {
|
|
401
|
-
result.deprecated = deprecated
|
|
402
|
-
}
|
|
403
|
-
const explode = this._getValue(object, ns.aml.vocabularies.apiContract.explode, objectContext)
|
|
404
|
-
if (typeof explode === 'boolean') {
|
|
405
|
-
result.explode = explode
|
|
406
|
-
}
|
|
407
|
-
const allowReserved = this._getValue(object, ns.aml.vocabularies.apiContract.allowReserved, objectContext)
|
|
408
|
-
if (typeof allowReserved === 'boolean') {
|
|
409
|
-
result.allowReserved = allowReserved
|
|
410
|
-
}
|
|
411
|
-
const style = this._getValue(object, ns.aml.vocabularies.apiContract.style, objectContext)
|
|
412
|
-
if (style && typeof style === 'string') {
|
|
413
|
-
result.style = style
|
|
414
|
-
}
|
|
415
|
-
const binding = this._getValue(object, ns.aml.vocabularies.apiContract.binding, objectContext)
|
|
416
|
-
if (binding && typeof binding === 'string') {
|
|
417
|
-
result.binding = binding
|
|
418
|
-
}
|
|
419
|
-
const schemas = object[
|
|
420
|
-
this._getAmfKey(ns.aml.vocabularies.shapes.schema, objectContext) as keyof IAmfParameter
|
|
421
|
-
] as IAmfShape[]
|
|
422
|
-
if (Array.isArray(schemas) && schemas.length) {
|
|
423
|
-
const [schema] = schemas
|
|
424
|
-
result.schema = this.unknownShape(
|
|
425
|
-
schema,
|
|
426
|
-
{
|
|
427
|
-
trackedId: object['@id'],
|
|
428
|
-
},
|
|
429
|
-
objectContext
|
|
430
|
-
)
|
|
431
|
-
}
|
|
432
|
-
const payloads = object[
|
|
433
|
-
this._getAmfKey(ns.aml.vocabularies.apiContract.payload, objectContext) as keyof IAmfParameter
|
|
434
|
-
] as IAmfPayload[]
|
|
435
|
-
if (Array.isArray(payloads) && payloads.length) {
|
|
436
|
-
result.payloads = payloads.map((p) => this.payload(p, objectContext))
|
|
437
|
-
}
|
|
438
|
-
const examples = object[
|
|
439
|
-
this._getAmfKey(ns.aml.vocabularies.apiContract.examples, objectContext) as keyof IAmfParameter
|
|
440
|
-
] as IAmfParameter[]
|
|
441
|
-
if (Array.isArray(examples) && examples.length) {
|
|
442
|
-
result.examples = examples.map((e) => this.example(e, objectContext))
|
|
443
|
-
}
|
|
444
|
-
return result
|
|
445
|
-
}
|
|
446
|
-
|
|
447
|
-
unknownShape(object: IAmfShape, options?: IShapeProcessingOptions, context?: Record<string, string>): IShapeUnion {
|
|
448
|
-
const objectContext = context || object['@context']
|
|
449
|
-
const types = this.readTypes(object['@type'], objectContext)
|
|
450
|
-
|
|
451
|
-
if (types.includes(ns.aml.vocabularies.shapes.ScalarShape)) {
|
|
452
|
-
return this.scalarShape(object as IAmfScalarShape, options, objectContext)
|
|
453
|
-
}
|
|
454
|
-
if (types.includes(ns.w3.shacl.NodeShape)) {
|
|
455
|
-
return this.nodeShape(object as IAmfNodeShape, options, objectContext)
|
|
456
|
-
}
|
|
457
|
-
if (types.includes(ns.aml.vocabularies.shapes.UnionShape)) {
|
|
458
|
-
return this.unionShape(object as IAmfUnionShape, options, objectContext)
|
|
459
|
-
}
|
|
460
|
-
if (types.includes(ns.aml.vocabularies.shapes.FileShape)) {
|
|
461
|
-
return this.fileShape(object as IAmfFileShape, options, objectContext)
|
|
462
|
-
}
|
|
463
|
-
if (types.includes(ns.aml.vocabularies.shapes.SchemaShape)) {
|
|
464
|
-
return this.schemaShape(object as IAmfSchemaShape, options, objectContext)
|
|
465
|
-
}
|
|
466
|
-
// this must be before the ArrayShape
|
|
467
|
-
if (types.includes(ns.aml.vocabularies.shapes.TupleShape)) {
|
|
468
|
-
return this.tupleShape(object as IAmfTupleShape, options, objectContext)
|
|
469
|
-
}
|
|
470
|
-
if (
|
|
471
|
-
types.includes(ns.aml.vocabularies.shapes.ArrayShape) ||
|
|
472
|
-
types.includes(ns.aml.vocabularies.shapes.MatrixShape)
|
|
473
|
-
) {
|
|
474
|
-
return this.arrayShape(object as IAmfArrayShape, options, objectContext)
|
|
475
|
-
}
|
|
476
|
-
if (types.includes(ns.aml.vocabularies.shapes.RecursiveShape)) {
|
|
477
|
-
return this.recursiveShape(object as IAmfRecursiveShape, objectContext)
|
|
478
|
-
}
|
|
479
|
-
// recursiveShape
|
|
480
|
-
return this.anyShape(object as IAmfAnyShape, options, objectContext)
|
|
481
|
-
}
|
|
482
|
-
|
|
483
|
-
isLink(object: IAmfDomainElement, context?: Record<string, string>): boolean {
|
|
484
|
-
const objectContext = context || object['@context']
|
|
485
|
-
return !!this._getLinkValue(object, ns.aml.vocabularies.document.linkTarget, objectContext)
|
|
486
|
-
}
|
|
487
|
-
|
|
488
|
-
getLinkTarget<T extends IAmfDomainElement>(object: T, context?: Record<string, string>): T | undefined {
|
|
489
|
-
const objectContext = context || object['@context']
|
|
490
|
-
const id = this._getLinkValue(object, ns.aml.vocabularies.document.linkTarget, objectContext)
|
|
491
|
-
if (!id) {
|
|
492
|
-
return undefined
|
|
493
|
-
}
|
|
494
|
-
return this[findAmfType](id, objectContext) as T | undefined
|
|
495
|
-
}
|
|
496
|
-
|
|
497
|
-
shape(object: IAmfShape, context?: Record<string, string>): IApiShape {
|
|
498
|
-
const objectContext = context || object['@context']
|
|
499
|
-
this._resolve(object)
|
|
500
|
-
let linkLabel: string | undefined
|
|
501
|
-
let target = object
|
|
502
|
-
if (this.isLink(target)) {
|
|
503
|
-
linkLabel = this._getValue(target, ns.aml.vocabularies.document.linkLabel, objectContext) as string
|
|
504
|
-
const id = this._getLinkValue(target, ns.aml.vocabularies.document.linkTarget, objectContext)
|
|
505
|
-
const value = this[findAmfType](id, objectContext) as IAmfShape | undefined
|
|
506
|
-
if (value) {
|
|
507
|
-
target = value
|
|
508
|
-
}
|
|
509
|
-
}
|
|
510
|
-
const result: IApiShape = {
|
|
511
|
-
id: target['@id'],
|
|
512
|
-
types: this.readTypes(object['@type'], objectContext),
|
|
513
|
-
values: [],
|
|
514
|
-
inherits: [],
|
|
515
|
-
or: [],
|
|
516
|
-
and: [],
|
|
517
|
-
xone: [],
|
|
518
|
-
customDomainProperties: this.customDomainProperties(object, objectContext),
|
|
519
|
-
sourceMaps: this.sourceMap(object, objectContext),
|
|
520
|
-
}
|
|
521
|
-
if (linkLabel) {
|
|
522
|
-
result.linkLabel = linkLabel
|
|
523
|
-
}
|
|
524
|
-
|
|
525
|
-
const name = this._getValue(target, ns.w3.shacl.name, objectContext)
|
|
526
|
-
if (name && typeof name === 'string') {
|
|
527
|
-
result.name = name
|
|
528
|
-
}
|
|
529
|
-
const displayName = this._getValue(target, ns.aml.vocabularies.core.displayName, objectContext)
|
|
530
|
-
if (displayName && typeof displayName === 'string') {
|
|
531
|
-
result.displayName = displayName
|
|
532
|
-
} else {
|
|
533
|
-
const coreName = this._getValue(target, ns.aml.vocabularies.core.name, objectContext)
|
|
534
|
-
if (coreName && typeof coreName === 'string') {
|
|
535
|
-
result.displayName = coreName
|
|
536
|
-
}
|
|
537
|
-
}
|
|
538
|
-
const description = this._getValue(target, ns.aml.vocabularies.core.description, objectContext)
|
|
539
|
-
if (description && typeof description === 'string') {
|
|
540
|
-
result.description = description
|
|
541
|
-
}
|
|
542
|
-
const defaultValueStr = this._getValue(target, ns.w3.shacl.defaultValueStr, objectContext)
|
|
543
|
-
if (defaultValueStr && typeof defaultValueStr === 'string') {
|
|
544
|
-
result.defaultValueStr = defaultValueStr
|
|
545
|
-
}
|
|
546
|
-
const deprecated = this._getValue(target, ns.aml.vocabularies.shapes.deprecated, objectContext)
|
|
547
|
-
if (typeof deprecated === 'boolean') {
|
|
548
|
-
result.deprecated = deprecated
|
|
549
|
-
}
|
|
550
|
-
const readOnly = this._getValue(target, ns.aml.vocabularies.shapes.readOnly, objectContext)
|
|
551
|
-
if (typeof readOnly === 'boolean') {
|
|
552
|
-
result.readOnly = readOnly
|
|
553
|
-
}
|
|
554
|
-
const writeOnly = this._getValue(target, ns.aml.vocabularies.shapes.writeOnly, objectContext)
|
|
555
|
-
if (typeof writeOnly === 'boolean') {
|
|
556
|
-
result.writeOnly = writeOnly
|
|
557
|
-
}
|
|
558
|
-
const defValue = target[this._getAmfKey(ns.w3.shacl.defaultValue, objectContext) as keyof IAmfShape]
|
|
559
|
-
if (Array.isArray(defValue) && defValue.length) {
|
|
560
|
-
result.defaultValue = this.unknownDataNode(defValue[0] as IAmfDataNode, objectContext)
|
|
561
|
-
}
|
|
562
|
-
// @TODO:
|
|
563
|
-
// if (Array.isArray(inherits) && inherits.length) {
|
|
564
|
-
// result.inherits = inherits.map((item) => this.unknownShape(item));
|
|
565
|
-
// }
|
|
566
|
-
const orKey = this._getAmfKey(ns.w3.shacl.or, objectContext) as keyof IAmfShape
|
|
567
|
-
const orGroup = target[orKey] as IAmfShape[]
|
|
568
|
-
if (Array.isArray(orGroup) && orGroup.length) {
|
|
569
|
-
result.or = orGroup.map((item) => this.unknownShape(item, undefined, objectContext))
|
|
570
|
-
}
|
|
571
|
-
const andKey = this._getAmfKey(ns.w3.shacl.and, objectContext) as keyof IAmfShape
|
|
572
|
-
const andGroup = target[andKey] as IAmfShape[]
|
|
573
|
-
if (Array.isArray(andGroup) && andGroup.length) {
|
|
574
|
-
result.and = andGroup.map((item) => this.unknownShape(item, undefined, objectContext))
|
|
575
|
-
}
|
|
576
|
-
const xoneKey = this._getAmfKey(ns.w3.shacl.xone, objectContext) as keyof IAmfShape
|
|
577
|
-
const xone = target[xoneKey] as IAmfShape[]
|
|
578
|
-
if (Array.isArray(xone) && xone.length) {
|
|
579
|
-
result.xone = xone.map((item) => this.unknownShape(item, undefined, objectContext))
|
|
580
|
-
}
|
|
581
|
-
|
|
582
|
-
const valuesList = target[this._getAmfKey(ns.w3.shacl.in, objectContext) as keyof IAmfShape]
|
|
583
|
-
if (Array.isArray(valuesList) && valuesList.length) {
|
|
584
|
-
const [values] = valuesList
|
|
585
|
-
const prefix = ns.w3.rdfSchema.key
|
|
586
|
-
const prefixCompact = this._getAmfKey(prefix, objectContext) as string
|
|
587
|
-
Object.keys(values).forEach((key) => {
|
|
588
|
-
if (key.startsWith(prefix) || key.startsWith(prefixCompact)) {
|
|
589
|
-
let value = (values as unknown as Record<string, IAmfDataNode>)[key]
|
|
590
|
-
if (Array.isArray(value)) {
|
|
591
|
-
;[value] = value
|
|
592
|
-
}
|
|
593
|
-
const processed = this.unknownDataNode(value, objectContext)
|
|
594
|
-
if (processed) {
|
|
595
|
-
result.values.push(processed)
|
|
596
|
-
}
|
|
597
|
-
}
|
|
598
|
-
})
|
|
599
|
-
}
|
|
600
|
-
const notKey = this._getAmfKey(ns.w3.shacl.not, objectContext) as keyof IAmfShape
|
|
601
|
-
let not = target[notKey] as IAmfShape | undefined
|
|
602
|
-
if (not) {
|
|
603
|
-
if (Array.isArray(not)) {
|
|
604
|
-
;[not] = not
|
|
605
|
-
}
|
|
606
|
-
result.not = this.unknownShape(not as IAmfShape, undefined, objectContext)
|
|
607
|
-
}
|
|
608
|
-
return result
|
|
609
|
-
}
|
|
610
|
-
|
|
611
|
-
anyShape(
|
|
612
|
-
object: IAmfAnyShape,
|
|
613
|
-
options: IShapeProcessingOptions = {},
|
|
614
|
-
context?: Record<string, string>
|
|
615
|
-
): IApiAnyShape {
|
|
616
|
-
const objectContext = context || object['@context']
|
|
617
|
-
let target = object
|
|
618
|
-
const result = this.shape(target, objectContext) as IApiAnyShape
|
|
619
|
-
if (this.isLink(target)) {
|
|
620
|
-
const value = this.getLinkTarget(target, objectContext) as IAmfShape | undefined
|
|
621
|
-
if (value) {
|
|
622
|
-
target = value
|
|
623
|
-
}
|
|
624
|
-
}
|
|
625
|
-
result.examples = []
|
|
626
|
-
const examples = target[
|
|
627
|
-
this._getAmfKey(ns.aml.vocabularies.apiContract.examples, objectContext) as keyof IAmfAnyShape
|
|
628
|
-
] as IAmfExample[]
|
|
629
|
-
|
|
630
|
-
if (Array.isArray(examples) && examples.length) {
|
|
631
|
-
if (options.trackedId) {
|
|
632
|
-
const filtered = this.filterTrackedExamples(examples, options.trackedId, objectContext)
|
|
633
|
-
result.examples = filtered.map((item) => this.example(item, objectContext))
|
|
634
|
-
} else {
|
|
635
|
-
const filtered = this.filterNonTrackedExamples(examples, objectContext)
|
|
636
|
-
result.examples = filtered.map((item) => this.example(item, objectContext))
|
|
637
|
-
}
|
|
638
|
-
}
|
|
639
|
-
const docs = target[
|
|
640
|
-
this._getAmfKey(ns.aml.vocabularies.core.documentation, objectContext) as keyof IAmfAnyShape
|
|
641
|
-
] as IAmfCreativeWork[] | undefined
|
|
642
|
-
if (Array.isArray(docs) && docs.length) {
|
|
643
|
-
const [documentation] = docs
|
|
644
|
-
result.documentation = this.documentation(documentation, objectContext)
|
|
645
|
-
}
|
|
646
|
-
const xml = target[
|
|
647
|
-
this._getAmfKey(ns.aml.vocabularies.shapes.xmlSerialization, objectContext) as keyof IAmfAnyShape
|
|
648
|
-
] as IAmfXMLSerializer[] | undefined
|
|
649
|
-
if (Array.isArray(xml) && xml.length) {
|
|
650
|
-
result.xmlSerialization = this.xmlSerializer(xml[0] as IAmfXMLSerializer, objectContext)
|
|
651
|
-
}
|
|
652
|
-
return result
|
|
653
|
-
}
|
|
654
|
-
|
|
655
|
-
/**
|
|
656
|
-
* Filters examples that should be rendered for a payload identified by `trackedId`.
|
|
657
|
-
*
|
|
658
|
-
* This function is copied from old `api-example-generator/ExampleGenerator`.
|
|
659
|
-
*/
|
|
660
|
-
filterTrackedExamples(examples: IAmfExample[], trackedId: string, context?: Record<string, string>): IAmfExample[] {
|
|
661
|
-
const { docSourceMaps } = ns.aml.vocabularies
|
|
662
|
-
const sourceKey = this._getAmfKey(docSourceMaps.sources, context) as keyof IAmfExample
|
|
663
|
-
const trackedKey = this._getAmfKey(docSourceMaps.trackedElement, context) as keyof IAmfDocumentSourceMaps
|
|
664
|
-
const longId = trackedId.indexOf('amf') === -1 ? `amf://id${trackedId}` : trackedId
|
|
665
|
-
return examples.filter((item) => {
|
|
666
|
-
let example = item
|
|
667
|
-
if (Array.isArray(example)) {
|
|
668
|
-
;[example] = example
|
|
669
|
-
}
|
|
670
|
-
let sm = example[sourceKey] as IAmfDocumentSourceMaps[] | IAmfDocumentSourceMaps | undefined
|
|
671
|
-
if (!sm) {
|
|
672
|
-
return true
|
|
673
|
-
}
|
|
674
|
-
if (Array.isArray(sm)) {
|
|
675
|
-
;[sm] = sm
|
|
676
|
-
}
|
|
677
|
-
let tracked = sm[trackedKey] as IAmfSynthesizedField[] | IAmfSynthesizedField | undefined
|
|
678
|
-
if (!tracked) {
|
|
679
|
-
return true
|
|
680
|
-
}
|
|
681
|
-
if (Array.isArray(tracked)) {
|
|
682
|
-
;[tracked] = tracked
|
|
683
|
-
}
|
|
684
|
-
const { value } = this.synthesizedField(tracked, context)
|
|
685
|
-
if (!value) {
|
|
686
|
-
return true
|
|
687
|
-
}
|
|
688
|
-
const ids = value.split(',')
|
|
689
|
-
if (ids.indexOf(longId) !== -1 || ids.indexOf(trackedId) !== -1) {
|
|
690
|
-
return true
|
|
691
|
-
}
|
|
692
|
-
return false
|
|
693
|
-
})
|
|
694
|
-
}
|
|
695
|
-
|
|
696
|
-
/**
|
|
697
|
-
* Kind of the opposite of the `filterTrackedExamples`. It gathers examples that only have been
|
|
698
|
-
* defined for the parent Shape (ed in the type declaration). It filters out all examples
|
|
699
|
-
* defined in a payload.
|
|
700
|
-
*/
|
|
701
|
-
filterNonTrackedExamples(examples: IAmfExample[], context?: Record<string, string>): IAmfExample[] {
|
|
702
|
-
const { docSourceMaps } = ns.aml.vocabularies
|
|
703
|
-
const sourceKey = this._getAmfKey(docSourceMaps.sources, context) as keyof IAmfExample
|
|
704
|
-
const trackedKey = this._getAmfKey(docSourceMaps.trackedElement, context) as keyof IAmfDocumentSourceMaps
|
|
705
|
-
return examples.filter((item) => {
|
|
706
|
-
let example = item
|
|
707
|
-
if (Array.isArray(example)) {
|
|
708
|
-
;[example] = example
|
|
709
|
-
}
|
|
710
|
-
let sm = example[sourceKey] as IAmfDocumentSourceMaps[] | IAmfDocumentSourceMaps | undefined
|
|
711
|
-
if (!sm) {
|
|
712
|
-
return true
|
|
713
|
-
}
|
|
714
|
-
if (Array.isArray(sm)) {
|
|
715
|
-
;[sm] = sm
|
|
716
|
-
}
|
|
717
|
-
let tracked = sm[trackedKey] as IAmfSynthesizedField[] | IAmfSynthesizedField | undefined
|
|
718
|
-
if (!tracked) {
|
|
719
|
-
return true
|
|
720
|
-
}
|
|
721
|
-
if (Array.isArray(tracked)) {
|
|
722
|
-
;[tracked] = tracked
|
|
723
|
-
}
|
|
724
|
-
const { value } = this.synthesizedField(tracked, context)
|
|
725
|
-
if (!value) {
|
|
726
|
-
return true
|
|
727
|
-
}
|
|
728
|
-
return false
|
|
729
|
-
})
|
|
730
|
-
}
|
|
731
|
-
|
|
732
|
-
scalarShape(
|
|
733
|
-
object: IAmfScalarShape,
|
|
734
|
-
options: IShapeProcessingOptions = {},
|
|
735
|
-
context?: Record<string, string>
|
|
736
|
-
): IApiScalarShape {
|
|
737
|
-
const objectContext = context || object['@context']
|
|
738
|
-
let target = object
|
|
739
|
-
const result = this.anyShape(target, options, objectContext) as IApiScalarShape
|
|
740
|
-
if (this.isLink(target)) {
|
|
741
|
-
const value = this.getLinkTarget(target, objectContext) as IAmfScalarShape | undefined
|
|
742
|
-
if (value) {
|
|
743
|
-
target = value
|
|
744
|
-
}
|
|
745
|
-
}
|
|
746
|
-
|
|
747
|
-
const pattern = this._getValue(target, ns.w3.shacl.pattern, objectContext)
|
|
748
|
-
if (pattern && typeof pattern === 'string') {
|
|
749
|
-
result.pattern = pattern
|
|
750
|
-
}
|
|
751
|
-
const dataType = this._getLinkValue(target, ns.w3.shacl.datatype, objectContext)
|
|
752
|
-
if (dataType && typeof dataType === 'string') {
|
|
753
|
-
result.dataType = dataType
|
|
754
|
-
}
|
|
755
|
-
const format = this._getValue(target, ns.aml.vocabularies.shapes.format, objectContext)
|
|
756
|
-
if (format && typeof format === 'string') {
|
|
757
|
-
result.format = format
|
|
758
|
-
}
|
|
759
|
-
const multipleOf = this._getValue(target, ns.aml.vocabularies.shapes.multipleOf, objectContext)
|
|
760
|
-
if (typeof multipleOf === 'number') {
|
|
761
|
-
result.multipleOf = multipleOf
|
|
762
|
-
}
|
|
763
|
-
const minInclusive = this._getValue(target, ns.w3.shacl.minInclusive, objectContext)
|
|
764
|
-
if (typeof minInclusive === 'number') {
|
|
765
|
-
result.minimum = minInclusive
|
|
766
|
-
result.exclusiveMinimum = false
|
|
767
|
-
}
|
|
768
|
-
const maxInclusive = this._getValue(target, ns.w3.shacl.maxInclusive, objectContext)
|
|
769
|
-
if (typeof maxInclusive === 'number') {
|
|
770
|
-
result.maximum = maxInclusive
|
|
771
|
-
result.exclusiveMaximum = false
|
|
772
|
-
}
|
|
773
|
-
const minLength = this._getValue(target, ns.w3.shacl.minLength, objectContext)
|
|
774
|
-
if (typeof minLength === 'number') {
|
|
775
|
-
result.minLength = minLength
|
|
776
|
-
}
|
|
777
|
-
const maxLength = this._getValue(target, ns.w3.shacl.maxLength, objectContext)
|
|
778
|
-
if (typeof maxLength === 'number') {
|
|
779
|
-
result.maxLength = maxLength
|
|
780
|
-
}
|
|
781
|
-
return result
|
|
782
|
-
}
|
|
783
|
-
|
|
784
|
-
nodeShape(
|
|
785
|
-
object: IAmfNodeShape,
|
|
786
|
-
options: IShapeProcessingOptions = {},
|
|
787
|
-
context?: Record<string, string>
|
|
788
|
-
): IApiNodeShape {
|
|
789
|
-
const objectContext = context || object['@context']
|
|
790
|
-
let target = object
|
|
791
|
-
const result = this.anyShape(target, options, objectContext) as IApiNodeShape
|
|
792
|
-
if (this.isLink(target)) {
|
|
793
|
-
const value = this.getLinkTarget(target, objectContext)
|
|
794
|
-
if (value) {
|
|
795
|
-
target = value
|
|
796
|
-
}
|
|
797
|
-
}
|
|
798
|
-
|
|
799
|
-
const discriminator = this._getValue(target, ns.aml.vocabularies.shapes.discriminator, objectContext)
|
|
800
|
-
if (discriminator && typeof discriminator === 'string') {
|
|
801
|
-
result.discriminator = discriminator
|
|
802
|
-
}
|
|
803
|
-
const discriminatorValue = this._getValue(target, ns.aml.vocabularies.shapes.discriminatorValue, objectContext)
|
|
804
|
-
if (discriminatorValue && typeof discriminatorValue === 'string') {
|
|
805
|
-
result.discriminatorValue = discriminatorValue
|
|
806
|
-
}
|
|
807
|
-
const closed = this._getValue(target, ns.w3.shacl.closed, objectContext)
|
|
808
|
-
if (typeof closed === 'boolean') {
|
|
809
|
-
result.closed = closed
|
|
810
|
-
}
|
|
811
|
-
|
|
812
|
-
result.customShapeProperties = []
|
|
813
|
-
result.customShapePropertyDefinitions = []
|
|
814
|
-
result.dependencies = []
|
|
815
|
-
// todo: not sure what the keys are.
|
|
816
|
-
// if (!minProperties.isNull) {
|
|
817
|
-
// result.minProperties = minProperties.value();
|
|
818
|
-
// }
|
|
819
|
-
// if (!maxProperties.isNull) {
|
|
820
|
-
// result.maxProperties = maxProperties.value();
|
|
821
|
-
// }
|
|
822
|
-
// if (Array.isArray(customShapeProperties) && customShapeProperties.length) {
|
|
823
|
-
// result.customShapeProperties = customShapeProperties.map((item) => item.id);
|
|
824
|
-
// } else {
|
|
825
|
-
// result.customShapeProperties = [];
|
|
826
|
-
// }
|
|
827
|
-
// if (Array.isArray(customShapePropertyDefinitions) && customShapePropertyDefinitions.length) {
|
|
828
|
-
// result.customShapePropertyDefinitions = customShapePropertyDefinitions.map((item) => item.id);
|
|
829
|
-
// } else {
|
|
830
|
-
// result.customShapePropertyDefinitions = [];
|
|
831
|
-
// }
|
|
832
|
-
const properties = target[
|
|
833
|
-
this._getAmfKey(ns.w3.shacl.property, objectContext) as keyof IAmfNodeShape
|
|
834
|
-
] as IAmfPropertyShape[]
|
|
835
|
-
if (Array.isArray(properties) && properties.length) {
|
|
836
|
-
result.properties = properties.map((item) => this.propertyShape(item, objectContext))
|
|
837
|
-
} else {
|
|
838
|
-
result.properties = []
|
|
839
|
-
}
|
|
840
|
-
// if (Array.isArray(dependencies) && dependencies.length) {
|
|
841
|
-
// result.dependencies = dependencies.map((item) => item.id);
|
|
842
|
-
// } else {
|
|
843
|
-
// result.dependencies = [];
|
|
844
|
-
// }
|
|
845
|
-
return result
|
|
846
|
-
}
|
|
847
|
-
|
|
848
|
-
propertyShape(object: IAmfPropertyShape, context?: Record<string, string>): IApiPropertyShape {
|
|
849
|
-
const objectContext = context || object['@context']
|
|
850
|
-
let target = object
|
|
851
|
-
const result = this.shape(target, objectContext) as IApiPropertyShape
|
|
852
|
-
if (this.isLink(target)) {
|
|
853
|
-
const value = this.getLinkTarget(target, objectContext)
|
|
854
|
-
if (value) {
|
|
855
|
-
target = value
|
|
856
|
-
}
|
|
857
|
-
}
|
|
858
|
-
|
|
859
|
-
const path = this._getLinkValue(target, ns.w3.shacl.path, objectContext)
|
|
860
|
-
if (path && typeof path === 'string') {
|
|
861
|
-
result.path = path
|
|
862
|
-
}
|
|
863
|
-
const minCount = this._getValue(target, ns.w3.shacl.minCount, objectContext)
|
|
864
|
-
if (typeof minCount === 'number') {
|
|
865
|
-
result.minCount = minCount
|
|
866
|
-
}
|
|
867
|
-
const maxCount = this._getValue(target, ns.w3.shacl.maxCount, objectContext)
|
|
868
|
-
if (typeof maxCount === 'number') {
|
|
869
|
-
result.maxCount = maxCount
|
|
870
|
-
}
|
|
871
|
-
// if (!patternName.isNullOrEmpty) {
|
|
872
|
-
// result.patternName = patternName.value();
|
|
873
|
-
// }
|
|
874
|
-
|
|
875
|
-
const ranges = target[
|
|
876
|
-
this._getAmfKey(ns.aml.vocabularies.shapes.range, objectContext) as keyof IAmfPropertyShape
|
|
877
|
-
] as IAmfShape[]
|
|
878
|
-
if (Array.isArray(ranges) && ranges.length) {
|
|
879
|
-
const [range] = ranges
|
|
880
|
-
result.range = this.unknownShape(range, undefined, objectContext)
|
|
881
|
-
}
|
|
882
|
-
return result
|
|
883
|
-
}
|
|
884
|
-
|
|
885
|
-
unionShape(
|
|
886
|
-
object: IAmfUnionShape,
|
|
887
|
-
options: IShapeProcessingOptions = {},
|
|
888
|
-
context?: Record<string, string>
|
|
889
|
-
): IApiUnionShape {
|
|
890
|
-
const objectContext = context || object['@context']
|
|
891
|
-
const anyOf = object[
|
|
892
|
-
this._getAmfKey(ns.aml.vocabularies.shapes.anyOf, objectContext) as keyof IAmfUnionShape
|
|
893
|
-
] as IAmfShape[]
|
|
894
|
-
const result = this.anyShape(object, options, objectContext) as IApiUnionShape
|
|
895
|
-
if (Array.isArray(anyOf) && anyOf.length) {
|
|
896
|
-
const opt = { ...options, trackedId: undefined }
|
|
897
|
-
result.anyOf = anyOf.map((shape) => this.unknownShape(shape, opt, objectContext))
|
|
898
|
-
} else {
|
|
899
|
-
result.anyOf = []
|
|
900
|
-
}
|
|
901
|
-
return result
|
|
902
|
-
}
|
|
903
|
-
|
|
904
|
-
fileShape(
|
|
905
|
-
object: IAmfFileShape,
|
|
906
|
-
options: IShapeProcessingOptions = {},
|
|
907
|
-
context?: Record<string, string>
|
|
908
|
-
): IApiFileShape {
|
|
909
|
-
const objectContext = context || object['@context']
|
|
910
|
-
let target = object
|
|
911
|
-
const result = this.anyShape(target, options, objectContext) as IApiFileShape
|
|
912
|
-
if (this.isLink(target)) {
|
|
913
|
-
const value = this.getLinkTarget(target, objectContext)
|
|
914
|
-
if (value) {
|
|
915
|
-
target = value
|
|
916
|
-
}
|
|
917
|
-
}
|
|
918
|
-
|
|
919
|
-
const pattern = this._getValue(target, ns.w3.shacl.pattern, objectContext)
|
|
920
|
-
if (pattern && typeof pattern === 'string') {
|
|
921
|
-
result.pattern = pattern
|
|
922
|
-
}
|
|
923
|
-
const fileTypes = this._getValueArray(target, ns.aml.vocabularies.shapes.fileType, objectContext) as
|
|
924
|
-
| string[]
|
|
925
|
-
| undefined
|
|
926
|
-
if (Array.isArray(fileTypes) && fileTypes.length) {
|
|
927
|
-
result.fileTypes = fileTypes
|
|
928
|
-
}
|
|
929
|
-
const minLength = this._getValue(target, ns.w3.shacl.minLength, objectContext)
|
|
930
|
-
if (typeof minLength === 'number') {
|
|
931
|
-
result.minLength = minLength
|
|
932
|
-
}
|
|
933
|
-
const maxLength = this._getValue(target, ns.w3.shacl.maxLength, objectContext)
|
|
934
|
-
if (typeof maxLength === 'number') {
|
|
935
|
-
result.maxLength = maxLength
|
|
936
|
-
}
|
|
937
|
-
const minInclusive = this._getValue(target, ns.w3.shacl.minInclusive, objectContext)
|
|
938
|
-
if (typeof minInclusive === 'number') {
|
|
939
|
-
result.minimum = minInclusive
|
|
940
|
-
result.exclusiveMinimum = false
|
|
941
|
-
}
|
|
942
|
-
const maxInclusive = this._getValue(target, ns.w3.shacl.maxInclusive, objectContext)
|
|
943
|
-
if (typeof maxInclusive === 'number') {
|
|
944
|
-
result.maximum = maxInclusive
|
|
945
|
-
result.exclusiveMaximum = false
|
|
946
|
-
}
|
|
947
|
-
const format = this._getValue(target, ns.aml.vocabularies.shapes.format, objectContext)
|
|
948
|
-
if (format && typeof format === 'string') {
|
|
949
|
-
result.format = format
|
|
950
|
-
}
|
|
951
|
-
const multipleOf = this._getValue(target, ns.aml.vocabularies.shapes.multipleOf, objectContext)
|
|
952
|
-
if (typeof multipleOf === 'number') {
|
|
953
|
-
result.multipleOf = multipleOf
|
|
954
|
-
}
|
|
955
|
-
return result
|
|
956
|
-
}
|
|
957
|
-
|
|
958
|
-
schemaShape(
|
|
959
|
-
object: IAmfSchemaShape,
|
|
960
|
-
options: IShapeProcessingOptions = {},
|
|
961
|
-
context?: Record<string, string>
|
|
962
|
-
): IApiSchemaShape {
|
|
963
|
-
const objectContext = context || object['@context']
|
|
964
|
-
let target = object
|
|
965
|
-
const result = this.anyShape(target, options, objectContext) as IApiSchemaShape
|
|
966
|
-
if (this.isLink(target)) {
|
|
967
|
-
const value = this.getLinkTarget(target, objectContext)
|
|
968
|
-
if (value) {
|
|
969
|
-
target = value
|
|
970
|
-
}
|
|
971
|
-
}
|
|
972
|
-
|
|
973
|
-
const mediaType = this._getValue(target, ns.aml.vocabularies.core.mediaType, objectContext)
|
|
974
|
-
if (mediaType && typeof mediaType === 'string') {
|
|
975
|
-
result.mediaType = mediaType
|
|
976
|
-
}
|
|
977
|
-
const raw = this._getValue(target, ns.aml.vocabularies.document.raw, objectContext)
|
|
978
|
-
if (raw && typeof raw === 'string') {
|
|
979
|
-
result.raw = raw
|
|
980
|
-
}
|
|
981
|
-
return result
|
|
982
|
-
}
|
|
983
|
-
|
|
984
|
-
recursiveShape(object: IAmfRecursiveShape, context?: Record<string, string>): IApiRecursiveShape {
|
|
985
|
-
const objectContext = context || object['@context']
|
|
986
|
-
let target = object
|
|
987
|
-
const result = this.shape(target, objectContext) as IApiRecursiveShape
|
|
988
|
-
if (this.isLink(target)) {
|
|
989
|
-
const value = this.getLinkTarget(target, objectContext)
|
|
990
|
-
if (value) {
|
|
991
|
-
target = value
|
|
992
|
-
}
|
|
993
|
-
}
|
|
994
|
-
|
|
995
|
-
const fp = this._getLinkValue(object, ns.aml.vocabularies.shapes.fixPoint, objectContext)
|
|
996
|
-
if (fp && typeof fp === 'string') {
|
|
997
|
-
result.fixPoint = fp
|
|
998
|
-
}
|
|
999
|
-
return result
|
|
1000
|
-
}
|
|
1001
|
-
|
|
1002
|
-
dataArrangeShape(
|
|
1003
|
-
object: IAmfDataArrangeShape,
|
|
1004
|
-
options: IShapeProcessingOptions = {},
|
|
1005
|
-
context?: Record<string, string>
|
|
1006
|
-
): IApiDataArrangeShape {
|
|
1007
|
-
const objectContext = context || object['@context']
|
|
1008
|
-
let target = object
|
|
1009
|
-
const result = this.anyShape(target, options, objectContext) as IApiDataArrangeShape
|
|
1010
|
-
if (this.isLink(target)) {
|
|
1011
|
-
const value = this.getLinkTarget(target, objectContext)
|
|
1012
|
-
if (value) {
|
|
1013
|
-
target = value
|
|
1014
|
-
}
|
|
1015
|
-
}
|
|
1016
|
-
//
|
|
1017
|
-
// const { minItems, maxItems, uniqueItems } = object;
|
|
1018
|
-
// if (!minItems.isNull) {
|
|
1019
|
-
// result.minItems = minItems.value();
|
|
1020
|
-
// }
|
|
1021
|
-
// if (!maxItems.isNull) {
|
|
1022
|
-
// result.maxItems = maxItems.value();
|
|
1023
|
-
// }
|
|
1024
|
-
// if (!uniqueItems.isNull) {
|
|
1025
|
-
// result.uniqueItems = uniqueItems.value();
|
|
1026
|
-
// }
|
|
1027
|
-
return result
|
|
1028
|
-
}
|
|
1029
|
-
|
|
1030
|
-
arrayShape(
|
|
1031
|
-
object: IAmfArrayShape,
|
|
1032
|
-
options: IShapeProcessingOptions = {},
|
|
1033
|
-
context?: Record<string, string>
|
|
1034
|
-
): IApiArrayShape {
|
|
1035
|
-
const objectContext = context || object['@context']
|
|
1036
|
-
let target = object
|
|
1037
|
-
const result = this.dataArrangeShape(target, options, objectContext) as IApiArrayShape
|
|
1038
|
-
if (this.isLink(target)) {
|
|
1039
|
-
const value = this.getLinkTarget(target, objectContext)
|
|
1040
|
-
if (value) {
|
|
1041
|
-
target = value
|
|
1042
|
-
}
|
|
1043
|
-
}
|
|
1044
|
-
|
|
1045
|
-
const items = target[this._getAmfKey(ns.aml.vocabularies.shapes.items, objectContext) as keyof IAmfArrayShape] as
|
|
1046
|
-
| IAmfShape[]
|
|
1047
|
-
| undefined
|
|
1048
|
-
if (Array.isArray(items) && items.length) {
|
|
1049
|
-
const [item] = items
|
|
1050
|
-
result.items = this.unknownShape(item, undefined, objectContext)
|
|
1051
|
-
}
|
|
1052
|
-
return result
|
|
1053
|
-
}
|
|
1054
|
-
|
|
1055
|
-
tupleShape(
|
|
1056
|
-
object: IAmfTupleShape,
|
|
1057
|
-
options?: IShapeProcessingOptions,
|
|
1058
|
-
context?: Record<string, string>
|
|
1059
|
-
): IApiTupleShape {
|
|
1060
|
-
const objectContext = context || object['@context']
|
|
1061
|
-
let target = object
|
|
1062
|
-
const result = this.dataArrangeShape(target, options, objectContext) as IApiTupleShape
|
|
1063
|
-
if (this.isLink(target)) {
|
|
1064
|
-
const value = this.getLinkTarget(target, objectContext)
|
|
1065
|
-
if (value) {
|
|
1066
|
-
target = value
|
|
1067
|
-
}
|
|
1068
|
-
}
|
|
1069
|
-
const items = target[this._getAmfKey(ns.aml.vocabularies.shapes.items, objectContext) as keyof IAmfTupleShape] as
|
|
1070
|
-
| IAmfShape[]
|
|
1071
|
-
| undefined
|
|
1072
|
-
const prefix = this._getAmfKey(ns.w3.rdfSchema.key, objectContext) as string
|
|
1073
|
-
if (Array.isArray(items) && items.length) {
|
|
1074
|
-
result.items = []
|
|
1075
|
-
items.forEach((item) => {
|
|
1076
|
-
if (Array.isArray(item)) {
|
|
1077
|
-
;[item] = item
|
|
1078
|
-
}
|
|
1079
|
-
Object.keys(item)
|
|
1080
|
-
.filter((k) => k.startsWith(prefix))
|
|
1081
|
-
.forEach((key) => {
|
|
1082
|
-
let shape = (item as unknown as Record<string, IAmfShape | IAmfShape[] | undefined>)[
|
|
1083
|
-
key as keyof IAmfShape
|
|
1084
|
-
] as IAmfShape
|
|
1085
|
-
if (Array.isArray(shape)) {
|
|
1086
|
-
;[shape] = shape
|
|
1087
|
-
}
|
|
1088
|
-
const value = this.unknownShape(shape, undefined, objectContext)
|
|
1089
|
-
result.items.push(value)
|
|
1090
|
-
})
|
|
1091
|
-
})
|
|
1092
|
-
} else {
|
|
1093
|
-
result.items = []
|
|
1094
|
-
}
|
|
1095
|
-
return result
|
|
1096
|
-
}
|
|
1097
|
-
|
|
1098
|
-
/**
|
|
1099
|
-
* @param object The CreativeWork to serialize.
|
|
1100
|
-
* @returns Serialized CreativeWork
|
|
1101
|
-
*/
|
|
1102
|
-
documentation(object: IAmfCreativeWork, context?: Record<string, string>): IApiDocumentation {
|
|
1103
|
-
const objectContext = context || object['@context']
|
|
1104
|
-
const result: IApiDocumentation = {
|
|
1105
|
-
id: object['@id'],
|
|
1106
|
-
types: this.readTypes(object['@type'], objectContext),
|
|
1107
|
-
customDomainProperties: this.customDomainProperties(object, objectContext),
|
|
1108
|
-
sourceMaps: this.sourceMap(object, objectContext),
|
|
1109
|
-
}
|
|
1110
|
-
const url = this._getLinkValue(object, ns.aml.vocabularies.core.url, objectContext)
|
|
1111
|
-
if (url && typeof url === 'string') {
|
|
1112
|
-
result.url = url
|
|
1113
|
-
}
|
|
1114
|
-
const description = this._getValue(object, ns.aml.vocabularies.core.description, objectContext)
|
|
1115
|
-
if (description && typeof description === 'string') {
|
|
1116
|
-
result.description = description
|
|
1117
|
-
}
|
|
1118
|
-
const title = this._getValue(object, ns.aml.vocabularies.core.title, objectContext)
|
|
1119
|
-
if (title && typeof title === 'string') {
|
|
1120
|
-
result.title = title
|
|
1121
|
-
}
|
|
1122
|
-
return result
|
|
1123
|
-
}
|
|
1124
|
-
|
|
1125
|
-
/**
|
|
1126
|
-
* @param object The Example to serialize.
|
|
1127
|
-
* @returns Serialized Example
|
|
1128
|
-
*/
|
|
1129
|
-
example(object: IAmfExample, context?: Record<string, string>): IApiDataExample {
|
|
1130
|
-
const objectContext = context || object['@context']
|
|
1131
|
-
this._resolve(object)
|
|
1132
|
-
const result: IApiDataExample = {
|
|
1133
|
-
id: object['@id'],
|
|
1134
|
-
types: this.readTypes(object['@type'], objectContext),
|
|
1135
|
-
customDomainProperties: this.customDomainProperties(object, objectContext),
|
|
1136
|
-
sourceMaps: this.sourceMap(object, objectContext),
|
|
1137
|
-
strict: false,
|
|
1138
|
-
}
|
|
1139
|
-
|
|
1140
|
-
const strict = this._getValue(object, ns.aml.vocabularies.document.strict, objectContext)
|
|
1141
|
-
if (typeof strict === 'boolean') {
|
|
1142
|
-
result.strict = strict
|
|
1143
|
-
}
|
|
1144
|
-
const name = this._getValue(object, ns.aml.vocabularies.core.name, objectContext)
|
|
1145
|
-
if (name && typeof name === 'string') {
|
|
1146
|
-
result.name = name
|
|
1147
|
-
}
|
|
1148
|
-
const displayName = this._getValue(object, ns.aml.vocabularies.core.displayName, objectContext)
|
|
1149
|
-
if (displayName && typeof displayName === 'string') {
|
|
1150
|
-
result.displayName = displayName
|
|
1151
|
-
}
|
|
1152
|
-
const description = this._getValue(object, ns.aml.vocabularies.core.description, objectContext)
|
|
1153
|
-
if (description && typeof description === 'string') {
|
|
1154
|
-
result.description = description
|
|
1155
|
-
}
|
|
1156
|
-
const raw = this._getValue(object, ns.aml.vocabularies.document.raw, objectContext)
|
|
1157
|
-
if (raw && typeof raw === 'string') {
|
|
1158
|
-
result.value = raw
|
|
1159
|
-
}
|
|
1160
|
-
const location = this._getValue(object, ns.aml.vocabularies.document.location, objectContext)
|
|
1161
|
-
if (location && typeof location === 'string') {
|
|
1162
|
-
result.location = location
|
|
1163
|
-
}
|
|
1164
|
-
// if (!mediaType.isNullOrEmpty) {
|
|
1165
|
-
// result.mediaType = mediaType.value();
|
|
1166
|
-
// }
|
|
1167
|
-
const structuredValue = object[
|
|
1168
|
-
this._getAmfKey(ns.aml.vocabularies.document.structuredValue, objectContext) as keyof IAmfExample
|
|
1169
|
-
] as IAmfDataNode[] | undefined
|
|
1170
|
-
if (Array.isArray(structuredValue) && structuredValue.length) {
|
|
1171
|
-
const [value] = structuredValue
|
|
1172
|
-
result.structuredValue = this.unknownDataNode(value, objectContext)
|
|
1173
|
-
}
|
|
1174
|
-
return result
|
|
1175
|
-
}
|
|
1176
|
-
|
|
1177
|
-
xmlSerializer(object: IAmfXMLSerializer, context?: Record<string, string>): IApiXmlSerializer {
|
|
1178
|
-
const objectContext = context || object['@context']
|
|
1179
|
-
const result: IApiXmlSerializer = {
|
|
1180
|
-
id: object['@id'],
|
|
1181
|
-
types: this.readTypes(object['@type'], objectContext),
|
|
1182
|
-
customDomainProperties: this.customDomainProperties(object, objectContext),
|
|
1183
|
-
sourceMaps: this.sourceMap(object, objectContext),
|
|
1184
|
-
}
|
|
1185
|
-
|
|
1186
|
-
const xmlAttribute = this._getValue(object, ns.aml.vocabularies.shapes.xmlAttribute, objectContext)
|
|
1187
|
-
if (typeof xmlAttribute === 'boolean') {
|
|
1188
|
-
result.attribute = xmlAttribute
|
|
1189
|
-
}
|
|
1190
|
-
const wrapped = this._getValue(object, ns.aml.vocabularies.shapes.xmlWrapped, objectContext)
|
|
1191
|
-
if (typeof wrapped === 'boolean') {
|
|
1192
|
-
result.wrapped = wrapped
|
|
1193
|
-
}
|
|
1194
|
-
const name = this._getValue(object, ns.aml.vocabularies.shapes.xmlName, objectContext)
|
|
1195
|
-
if (name && typeof name === 'string') {
|
|
1196
|
-
result.name = name
|
|
1197
|
-
}
|
|
1198
|
-
const xmlNs = this._getValue(object, ns.aml.vocabularies.shapes.xmlNamespace, objectContext)
|
|
1199
|
-
if (xmlNs && typeof xmlNs === 'string') {
|
|
1200
|
-
result.namespace = xmlNs
|
|
1201
|
-
}
|
|
1202
|
-
const xmlPrefix = this._getValue(object, ns.aml.vocabularies.shapes.xmlPrefix, objectContext)
|
|
1203
|
-
if (xmlPrefix && typeof xmlPrefix === 'string') {
|
|
1204
|
-
result.prefix = xmlPrefix
|
|
1205
|
-
}
|
|
1206
|
-
return result
|
|
1207
|
-
}
|
|
1208
|
-
|
|
1209
|
-
unknownDataNode(object: IAmfDataNode, context?: Record<string, string>): IApiDataNodeUnion | undefined {
|
|
1210
|
-
const types = this.readTypes(object['@type'], context)
|
|
1211
|
-
|
|
1212
|
-
if (types.includes(ns.aml.vocabularies.data.Scalar)) {
|
|
1213
|
-
return this.scalarNode(object as IAmfScalarNode, context)
|
|
1214
|
-
}
|
|
1215
|
-
if (types.includes(ns.aml.vocabularies.data.Object)) {
|
|
1216
|
-
return this.objectNode(object as IAmfObjectNode, context)
|
|
1217
|
-
}
|
|
1218
|
-
if (types.includes(ns.aml.vocabularies.data.Array)) {
|
|
1219
|
-
return this.arrayNode(object as IAmfArrayNode, context)
|
|
1220
|
-
}
|
|
1221
|
-
return undefined
|
|
1222
|
-
}
|
|
1223
|
-
|
|
1224
|
-
dataNode(object: IAmfDataNode, context?: Record<string, string>): IApiDataNode {
|
|
1225
|
-
const result: IApiDataNode = {
|
|
1226
|
-
id: object['@id'],
|
|
1227
|
-
types: this.readTypes(object['@type'], context),
|
|
1228
|
-
customDomainProperties: this.customDomainProperties(object, context),
|
|
1229
|
-
}
|
|
1230
|
-
|
|
1231
|
-
const name = this._getValue(object, ns.aml.vocabularies.core.name, context)
|
|
1232
|
-
if (name && typeof name === 'string') {
|
|
1233
|
-
result.name = name
|
|
1234
|
-
}
|
|
1235
|
-
return result
|
|
1236
|
-
}
|
|
1237
|
-
|
|
1238
|
-
scalarNode(object: IAmfScalarNode, context?: Record<string, string>): IApiScalarNode {
|
|
1239
|
-
const objectContext = context || object['@context']
|
|
1240
|
-
const result = this.dataNode(object, context) as IApiScalarNode
|
|
1241
|
-
|
|
1242
|
-
const value = this._getValue(object, ns.aml.vocabularies.data.value, objectContext)
|
|
1243
|
-
if (value && typeof value === 'string') {
|
|
1244
|
-
result.value = value
|
|
1245
|
-
}
|
|
1246
|
-
const dataType = this._getLinkValue(object, ns.w3.shacl.datatype, objectContext)
|
|
1247
|
-
if (dataType && typeof dataType === 'string') {
|
|
1248
|
-
result.dataType = dataType
|
|
1249
|
-
}
|
|
1250
|
-
return result
|
|
1251
|
-
}
|
|
1252
|
-
|
|
1253
|
-
objectNode(object: IAmfObjectNode, context?: Record<string, string>): IApiObjectNode {
|
|
1254
|
-
const objectContext = context || object['@context']
|
|
1255
|
-
const result = this.dataNode(object, context) as IApiObjectNode
|
|
1256
|
-
result.properties = {}
|
|
1257
|
-
const prefix = ns.aml.vocabularies.data.key
|
|
1258
|
-
const prefixCompact = `${this._getAmfKey(prefix, objectContext)}:`
|
|
1259
|
-
Object.keys(object).forEach((key) => {
|
|
1260
|
-
if (key.startsWith(prefix) || key.startsWith(prefixCompact)) {
|
|
1261
|
-
let value = object[key as keyof IAmfObjectNode] as IAmfDataNode | undefined
|
|
1262
|
-
if (Array.isArray(value)) {
|
|
1263
|
-
;[value] = value
|
|
1264
|
-
}
|
|
1265
|
-
const name = key.replace(prefix, '').replace(prefixCompact, '')
|
|
1266
|
-
const nodeValue = this.unknownDataNode(value as IAmfDataNode, context)
|
|
1267
|
-
if (nodeValue) {
|
|
1268
|
-
result.properties[name] = nodeValue
|
|
1269
|
-
}
|
|
1270
|
-
}
|
|
1271
|
-
})
|
|
1272
|
-
return result
|
|
1273
|
-
}
|
|
1274
|
-
|
|
1275
|
-
arrayNode(object: IAmfArrayNode, context?: Record<string, string>): IApiArrayNode {
|
|
1276
|
-
const objectContext = context || object['@context']
|
|
1277
|
-
const result = this.dataNode(object, objectContext) as IApiArrayNode
|
|
1278
|
-
result.members = []
|
|
1279
|
-
const members = this._computePropertyArray(object, ns.w3.rdfSchema.member) as IAmfDataNode[]
|
|
1280
|
-
if (Array.isArray(members) && members.length) {
|
|
1281
|
-
members.forEach((n) => {
|
|
1282
|
-
const item = this.unknownDataNode(n)
|
|
1283
|
-
if (item) {
|
|
1284
|
-
result.members.push(item)
|
|
1285
|
-
}
|
|
1286
|
-
})
|
|
1287
|
-
}
|
|
1288
|
-
return result
|
|
1289
|
-
}
|
|
1290
|
-
|
|
1291
|
-
/**
|
|
1292
|
-
* Adds the custom domain properties to the currently processed property, a.k.a annotations.
|
|
1293
|
-
* @returns The list of custom domain properties.
|
|
1294
|
-
*/
|
|
1295
|
-
customDomainProperties(object: IAmfDomainElement, context?: Record<string, string>): IApiCustomDomainProperty[] {
|
|
1296
|
-
const result: IApiCustomDomainProperty[] = []
|
|
1297
|
-
const objectContext = context || object['@context']
|
|
1298
|
-
const ids = this._getLinkValues(object, ns.aml.vocabularies.document.customDomainProperties, objectContext)
|
|
1299
|
-
if (Array.isArray(ids) && ids.length) {
|
|
1300
|
-
ids.forEach((id) => {
|
|
1301
|
-
const key = `amf://id${id}`
|
|
1302
|
-
let value = (object[id as keyof IAmfDomainElement] || object[key as keyof IAmfDomainElement]) as
|
|
1303
|
-
| IAmfDomainElement[]
|
|
1304
|
-
| IAmfDomainElement
|
|
1305
|
-
| undefined
|
|
1306
|
-
if (!value) {
|
|
1307
|
-
return
|
|
1308
|
-
}
|
|
1309
|
-
if (Array.isArray(value)) {
|
|
1310
|
-
;[value] = value
|
|
1311
|
-
}
|
|
1312
|
-
const extension = this.unknownDataNode(value, objectContext)
|
|
1313
|
-
const name = this._getValue(value, ns.aml.vocabularies.core.extensionName, objectContext) as string | undefined
|
|
1314
|
-
if (!name || !extension) {
|
|
1315
|
-
return
|
|
1316
|
-
}
|
|
1317
|
-
const cdp: IApiCustomDomainProperty = {
|
|
1318
|
-
id: key,
|
|
1319
|
-
name,
|
|
1320
|
-
extension,
|
|
1321
|
-
}
|
|
1322
|
-
result.push(cdp)
|
|
1323
|
-
})
|
|
1324
|
-
}
|
|
1325
|
-
return result
|
|
1326
|
-
}
|
|
1327
|
-
|
|
1328
|
-
endPoint(object: IAmfEndPoint, context?: Record<string, string>): IApiEndPoint {
|
|
1329
|
-
const objectContext = context || object['@context']
|
|
1330
|
-
const result: IApiEndPoint = {
|
|
1331
|
-
id: object['@id'],
|
|
1332
|
-
types: this.readTypes(object['@type'], objectContext),
|
|
1333
|
-
customDomainProperties: this.customDomainProperties(object, objectContext),
|
|
1334
|
-
sourceMaps: this.sourceMap(object),
|
|
1335
|
-
path: '',
|
|
1336
|
-
operations: [],
|
|
1337
|
-
parameters: [],
|
|
1338
|
-
payloads: [],
|
|
1339
|
-
servers: [],
|
|
1340
|
-
security: [],
|
|
1341
|
-
extends: [],
|
|
1342
|
-
}
|
|
1343
|
-
|
|
1344
|
-
const path = this._getValue(object, ns.aml.vocabularies.apiContract.path, objectContext)
|
|
1345
|
-
if (path && typeof path === 'string') {
|
|
1346
|
-
result.path = path
|
|
1347
|
-
}
|
|
1348
|
-
const name = this._getValue(object, ns.aml.vocabularies.core.name, objectContext)
|
|
1349
|
-
if (name && typeof name === 'string') {
|
|
1350
|
-
result.name = name
|
|
1351
|
-
}
|
|
1352
|
-
const description = this._getValue(object, ns.aml.vocabularies.core.description, objectContext)
|
|
1353
|
-
if (description && typeof description === 'string') {
|
|
1354
|
-
result.description = description
|
|
1355
|
-
}
|
|
1356
|
-
const summary = this._getValue(object, ns.aml.vocabularies.core.summary, objectContext)
|
|
1357
|
-
if (summary && typeof summary === 'string') {
|
|
1358
|
-
result.summary = summary
|
|
1359
|
-
}
|
|
1360
|
-
const operations = this[getArrayItems](object, ns.aml.vocabularies.apiContract.supportedOperation, objectContext)
|
|
1361
|
-
if (Array.isArray(operations) && operations.length) {
|
|
1362
|
-
result.operations = operations.map((i) => this.operation(i as IAmfOperation, objectContext))
|
|
1363
|
-
}
|
|
1364
|
-
const parameters = this[getArrayItems](object, ns.aml.vocabularies.apiContract.parameter, objectContext)
|
|
1365
|
-
if (Array.isArray(parameters) && parameters.length) {
|
|
1366
|
-
result.parameters = parameters.map((i) => this.parameter(i, objectContext))
|
|
1367
|
-
}
|
|
1368
|
-
const payloads = this[getArrayItems](object, ns.aml.vocabularies.apiContract.payload, objectContext)
|
|
1369
|
-
if (Array.isArray(payloads) && payloads.length) {
|
|
1370
|
-
result.payloads = payloads.map((i) => this.payload(/** @type IAmfPayload */ i as IAmfPayload, objectContext))
|
|
1371
|
-
}
|
|
1372
|
-
const servers = this[getArrayItems](object, ns.aml.vocabularies.apiContract.server, objectContext)
|
|
1373
|
-
if (Array.isArray(servers) && servers.length) {
|
|
1374
|
-
result.servers = servers.map((i) => this.server(i, objectContext))
|
|
1375
|
-
}
|
|
1376
|
-
const security = this[getArrayItems](object, ns.aml.vocabularies.security.security, objectContext)
|
|
1377
|
-
if (Array.isArray(security) && security.length) {
|
|
1378
|
-
result.security = security.map((i) => this.securityRequirement(i, objectContext))
|
|
1379
|
-
}
|
|
1380
|
-
const extensions = this[getArrayItems](object, ns.aml.vocabularies.document.extends, objectContext)
|
|
1381
|
-
if (Array.isArray(extensions) && extensions.length) {
|
|
1382
|
-
result.extends = []
|
|
1383
|
-
extensions.forEach((ex) => {
|
|
1384
|
-
let extension = ex
|
|
1385
|
-
if (Array.isArray(extension)) {
|
|
1386
|
-
;[extension] = extension
|
|
1387
|
-
}
|
|
1388
|
-
if (this._hasType(extension, ns.aml.vocabularies.apiContract.ParametrizedResourceType, objectContext)) {
|
|
1389
|
-
result.extends.push(this.parametrizedResourceType(extension, objectContext))
|
|
1390
|
-
} else if (this._hasType(extension, ns.aml.vocabularies.apiContract.ParametrizedTrait, objectContext)) {
|
|
1391
|
-
result.extends.push(this.parametrizedTrait(extension, objectContext))
|
|
1392
|
-
}
|
|
1393
|
-
})
|
|
1394
|
-
}
|
|
1395
|
-
return result
|
|
1396
|
-
}
|
|
1397
|
-
|
|
1398
|
-
operation(object: IAmfOperation, context?: Record<string, string>): IApiOperation {
|
|
1399
|
-
const objectContext = context || object['@context']
|
|
1400
|
-
const result: IApiOperation = {
|
|
1401
|
-
id: object['@id'],
|
|
1402
|
-
types: this.readTypes(object['@type'], objectContext),
|
|
1403
|
-
customDomainProperties: this.customDomainProperties(object, objectContext),
|
|
1404
|
-
sourceMaps: this.sourceMap(object),
|
|
1405
|
-
method: '',
|
|
1406
|
-
deprecated: false,
|
|
1407
|
-
callbacks: [],
|
|
1408
|
-
responses: [],
|
|
1409
|
-
servers: [],
|
|
1410
|
-
security: [],
|
|
1411
|
-
accepts: [],
|
|
1412
|
-
schemes: [],
|
|
1413
|
-
contentType: [],
|
|
1414
|
-
tags: [],
|
|
1415
|
-
extends: [],
|
|
1416
|
-
}
|
|
1417
|
-
|
|
1418
|
-
const method = this._getValue(object, ns.aml.vocabularies.apiContract.method, objectContext)
|
|
1419
|
-
if (method && typeof method === 'string') {
|
|
1420
|
-
result.method = method
|
|
1421
|
-
}
|
|
1422
|
-
const name = this._getValue(object, ns.aml.vocabularies.core.name, objectContext)
|
|
1423
|
-
if (name && typeof name === 'string') {
|
|
1424
|
-
result.name = name
|
|
1425
|
-
}
|
|
1426
|
-
const description = this._getValue(object, ns.aml.vocabularies.core.description, objectContext)
|
|
1427
|
-
if (description && typeof description === 'string') {
|
|
1428
|
-
result.description = description
|
|
1429
|
-
}
|
|
1430
|
-
const summary = this._getValue(object, ns.aml.vocabularies.apiContract.guiSummary, objectContext)
|
|
1431
|
-
if (summary && typeof summary === 'string') {
|
|
1432
|
-
result.summary = summary
|
|
1433
|
-
}
|
|
1434
|
-
const deprecated = this._getValue(object, ns.aml.vocabularies.core.deprecated, objectContext)
|
|
1435
|
-
if (typeof deprecated === 'boolean') {
|
|
1436
|
-
result.deprecated = deprecated
|
|
1437
|
-
}
|
|
1438
|
-
const operationId = this._getValue(object, ns.aml.vocabularies.apiContract.operationId, objectContext)
|
|
1439
|
-
if (operationId && typeof operationId === 'string') {
|
|
1440
|
-
result.operationId = operationId
|
|
1441
|
-
}
|
|
1442
|
-
const accepts = this._getValueArray(object, ns.aml.vocabularies.apiContract.accepts, objectContext) as string[]
|
|
1443
|
-
if (Array.isArray(accepts)) {
|
|
1444
|
-
result.accepts = accepts
|
|
1445
|
-
}
|
|
1446
|
-
const schemes = this._getValueArray(object, ns.aml.vocabularies.apiContract.scheme, objectContext) as string[]
|
|
1447
|
-
if (Array.isArray(schemes)) {
|
|
1448
|
-
result.schemes = schemes
|
|
1449
|
-
}
|
|
1450
|
-
const contentType = this._getValueArray(
|
|
1451
|
-
object,
|
|
1452
|
-
ns.aml.vocabularies.apiContract.contentType,
|
|
1453
|
-
objectContext
|
|
1454
|
-
) as string[]
|
|
1455
|
-
if (Array.isArray(contentType)) {
|
|
1456
|
-
result.contentType = contentType
|
|
1457
|
-
}
|
|
1458
|
-
|
|
1459
|
-
let expects = object[
|
|
1460
|
-
this._getAmfKey(ns.aml.vocabularies.apiContract.expects, objectContext) as keyof IAmfOperation
|
|
1461
|
-
] as IAmfRequest[] | IAmfRequest | undefined
|
|
1462
|
-
if (expects) {
|
|
1463
|
-
if (Array.isArray(expects)) {
|
|
1464
|
-
;[expects] = expects
|
|
1465
|
-
}
|
|
1466
|
-
result.request = this.request(expects, objectContext)
|
|
1467
|
-
}
|
|
1468
|
-
let documentation = object[
|
|
1469
|
-
this._getAmfKey(ns.aml.vocabularies.core.documentation, objectContext) as keyof IAmfOperation
|
|
1470
|
-
] as IAmfCreativeWork[] | IAmfCreativeWork | undefined
|
|
1471
|
-
if (documentation) {
|
|
1472
|
-
if (Array.isArray(documentation)) {
|
|
1473
|
-
;[documentation] = documentation
|
|
1474
|
-
}
|
|
1475
|
-
result.documentation = this.documentation(documentation, objectContext)
|
|
1476
|
-
}
|
|
1477
|
-
const responses = object[
|
|
1478
|
-
this._getAmfKey(ns.aml.vocabularies.apiContract.returns, objectContext) as keyof IAmfOperation
|
|
1479
|
-
] as IAmfResponse[] | undefined
|
|
1480
|
-
if (Array.isArray(responses)) {
|
|
1481
|
-
result.responses = responses.map((r) => this.response(r, objectContext))
|
|
1482
|
-
}
|
|
1483
|
-
const callbacks = object[
|
|
1484
|
-
this._getAmfKey(ns.aml.vocabularies.apiContract.callback, objectContext) as keyof IAmfOperation
|
|
1485
|
-
] as IAmfCallback[] | undefined
|
|
1486
|
-
if (Array.isArray(callbacks)) {
|
|
1487
|
-
result.callbacks = callbacks.map((c) => this.callback(c, objectContext))
|
|
1488
|
-
}
|
|
1489
|
-
const servers = object[
|
|
1490
|
-
this._getAmfKey(ns.aml.vocabularies.apiContract.server, objectContext) as keyof IAmfOperation
|
|
1491
|
-
] as IAmfServer[] | undefined
|
|
1492
|
-
if (Array.isArray(servers)) {
|
|
1493
|
-
result.servers = servers.map((s) => this.server(s))
|
|
1494
|
-
}
|
|
1495
|
-
const security = object[
|
|
1496
|
-
this._getAmfKey(ns.aml.vocabularies.security.security, objectContext) as keyof IAmfOperation
|
|
1497
|
-
] as IAmfSecurityRequirement[] | undefined
|
|
1498
|
-
if (Array.isArray(security)) {
|
|
1499
|
-
result.security = security.map((s) => this.securityRequirement(s, objectContext))
|
|
1500
|
-
}
|
|
1501
|
-
const tags = object[this._getAmfKey(ns.aml.vocabularies.apiContract.tag, objectContext) as keyof IAmfOperation] as
|
|
1502
|
-
| IAmfTag[]
|
|
1503
|
-
| undefined
|
|
1504
|
-
if (Array.isArray(tags) && tags.length) {
|
|
1505
|
-
result.tags = tags.map((s) => this.tag(s, objectContext))
|
|
1506
|
-
}
|
|
1507
|
-
const traits = object[
|
|
1508
|
-
this._getAmfKey(ns.aml.vocabularies.document.extends, objectContext) as keyof IAmfOperation
|
|
1509
|
-
] as IAmfParametrizedTrait[] | undefined
|
|
1510
|
-
if (Array.isArray(traits) && traits.length) {
|
|
1511
|
-
result.extends = traits.map((t) => this.parametrizedTrait(t, objectContext))
|
|
1512
|
-
}
|
|
1513
|
-
return result
|
|
1514
|
-
}
|
|
1515
|
-
|
|
1516
|
-
tag(object: IAmfTag, context?: Record<string, string>): IApiTag {
|
|
1517
|
-
const objectContext = context || object['@context']
|
|
1518
|
-
const result: IApiTag = {
|
|
1519
|
-
id: object['@id'],
|
|
1520
|
-
types: this.readTypes(object['@type'], objectContext),
|
|
1521
|
-
customDomainProperties: this.customDomainProperties(object, objectContext),
|
|
1522
|
-
sourceMaps: this.sourceMap(object),
|
|
1523
|
-
name: '',
|
|
1524
|
-
}
|
|
1525
|
-
const name = this._getValue(object, ns.aml.vocabularies.core.name, objectContext)
|
|
1526
|
-
if (name && typeof name === 'string') {
|
|
1527
|
-
result.name = name
|
|
1528
|
-
}
|
|
1529
|
-
return result
|
|
1530
|
-
}
|
|
1531
|
-
|
|
1532
|
-
callback(object: IAmfCallback, context?: Record<string, string>): IApiCallback {
|
|
1533
|
-
const objectContext = context || object['@context']
|
|
1534
|
-
const result: IApiCallback = {
|
|
1535
|
-
id: object['@id'],
|
|
1536
|
-
types: this.readTypes(object['@type'], objectContext),
|
|
1537
|
-
customDomainProperties: this.customDomainProperties(object, objectContext),
|
|
1538
|
-
sourceMaps: this.sourceMap(object),
|
|
1539
|
-
}
|
|
1540
|
-
|
|
1541
|
-
const name = this._getValue(object, ns.aml.vocabularies.core.name, objectContext)
|
|
1542
|
-
if (name && typeof name === 'string') {
|
|
1543
|
-
result.name = name
|
|
1544
|
-
}
|
|
1545
|
-
const expression = this._getValue(object, ns.aml.vocabularies.apiContract.expression, objectContext)
|
|
1546
|
-
if (expression && typeof expression === 'string') {
|
|
1547
|
-
result.expression = expression
|
|
1548
|
-
}
|
|
1549
|
-
let endpoint = object[
|
|
1550
|
-
this._getAmfKey(ns.aml.vocabularies.apiContract.endpoint, objectContext) as keyof IAmfCallback
|
|
1551
|
-
] as IAmfEndPoint[] | IAmfEndPoint | undefined
|
|
1552
|
-
if (endpoint) {
|
|
1553
|
-
if (Array.isArray(endpoint)) {
|
|
1554
|
-
;[endpoint] = endpoint
|
|
1555
|
-
}
|
|
1556
|
-
result.endpoint = this.endPoint(endpoint, objectContext)
|
|
1557
|
-
}
|
|
1558
|
-
return result
|
|
1559
|
-
}
|
|
1560
|
-
|
|
1561
|
-
request(object: IAmfRequest, context?: Record<string, string>): IApiRequest {
|
|
1562
|
-
const objectContext = context || object['@context']
|
|
1563
|
-
const result: IApiRequest = {
|
|
1564
|
-
id: object['@id'],
|
|
1565
|
-
types: this.readTypes(object['@type'], objectContext),
|
|
1566
|
-
customDomainProperties: this.customDomainProperties(object, objectContext),
|
|
1567
|
-
sourceMaps: this.sourceMap(object),
|
|
1568
|
-
required: false,
|
|
1569
|
-
headers: [],
|
|
1570
|
-
queryParameters: [],
|
|
1571
|
-
payloads: [],
|
|
1572
|
-
uriParameters: [],
|
|
1573
|
-
cookieParameters: [],
|
|
1574
|
-
}
|
|
1575
|
-
|
|
1576
|
-
const description = this._getValue(object, ns.aml.vocabularies.core.description, objectContext)
|
|
1577
|
-
if (description && typeof description === 'string') {
|
|
1578
|
-
result.description = description
|
|
1579
|
-
}
|
|
1580
|
-
const required = this._getValue(object, ns.aml.vocabularies.apiContract.required, objectContext)
|
|
1581
|
-
if (required && typeof required === 'boolean') {
|
|
1582
|
-
result.required = required
|
|
1583
|
-
}
|
|
1584
|
-
let queryString = object[
|
|
1585
|
-
this._getAmfKey(ns.aml.vocabularies.apiContract.queryString, objectContext) as keyof IAmfRequest
|
|
1586
|
-
] as IAmfShape[] | IAmfShape | undefined
|
|
1587
|
-
if (queryString) {
|
|
1588
|
-
if (Array.isArray(queryString)) {
|
|
1589
|
-
;[queryString] = queryString
|
|
1590
|
-
}
|
|
1591
|
-
result.queryString = this.unknownShape(queryString, undefined, objectContext)
|
|
1592
|
-
}
|
|
1593
|
-
const headers = this[getArrayItems](object, ns.aml.vocabularies.apiContract.header, objectContext)
|
|
1594
|
-
if (Array.isArray(headers) && headers.length) {
|
|
1595
|
-
result.headers = headers.map((p) => this.parameter(p, objectContext))
|
|
1596
|
-
}
|
|
1597
|
-
const queryParameters = this[getArrayItems](object, ns.aml.vocabularies.apiContract.parameter, objectContext)
|
|
1598
|
-
if (Array.isArray(queryParameters) && queryParameters.length) {
|
|
1599
|
-
result.queryParameters = queryParameters.map((p) => this.parameter(p, objectContext))
|
|
1600
|
-
}
|
|
1601
|
-
const uriParameters = this[getArrayItems](object, ns.aml.vocabularies.apiContract.uriParameter, objectContext)
|
|
1602
|
-
if (Array.isArray(uriParameters) && uriParameters.length) {
|
|
1603
|
-
result.uriParameters = uriParameters.map((p) => this.parameter(p, objectContext))
|
|
1604
|
-
}
|
|
1605
|
-
const cookieParameters = this[getArrayItems](object, ns.aml.vocabularies.apiContract.cookieParameter, objectContext)
|
|
1606
|
-
if (Array.isArray(cookieParameters) && cookieParameters.length) {
|
|
1607
|
-
result.cookieParameters = cookieParameters.map((p) => this.parameter(p, objectContext))
|
|
1608
|
-
}
|
|
1609
|
-
const payloads = this[getArrayItems](object, ns.aml.vocabularies.apiContract.payload, objectContext) as
|
|
1610
|
-
| IAmfPayload[]
|
|
1611
|
-
| undefined
|
|
1612
|
-
if (Array.isArray(payloads) && payloads.length) {
|
|
1613
|
-
result.payloads = payloads.map((p) => this.payload(p, objectContext))
|
|
1614
|
-
}
|
|
1615
|
-
return result
|
|
1616
|
-
}
|
|
1617
|
-
|
|
1618
|
-
response(object: IAmfResponse, context?: Record<string, string>): IApiResponse {
|
|
1619
|
-
const objectContext = context || object['@context']
|
|
1620
|
-
const result: IApiResponse = {
|
|
1621
|
-
id: object['@id'],
|
|
1622
|
-
types: this.readTypes(object['@type'], objectContext),
|
|
1623
|
-
customDomainProperties: this.customDomainProperties(object, objectContext),
|
|
1624
|
-
sourceMaps: this.sourceMap(object, objectContext),
|
|
1625
|
-
headers: [],
|
|
1626
|
-
payloads: [],
|
|
1627
|
-
examples: [],
|
|
1628
|
-
links: [],
|
|
1629
|
-
}
|
|
1630
|
-
|
|
1631
|
-
const name = this._getValue(object, ns.aml.vocabularies.core.name, objectContext)
|
|
1632
|
-
if (name && typeof name === 'string') {
|
|
1633
|
-
result.name = name
|
|
1634
|
-
}
|
|
1635
|
-
const description = this._getValue(object, ns.aml.vocabularies.core.description, objectContext)
|
|
1636
|
-
if (description && typeof description === 'string') {
|
|
1637
|
-
result.description = description
|
|
1638
|
-
}
|
|
1639
|
-
const statusCode = this._getValue(object, ns.aml.vocabularies.apiContract.statusCode, objectContext)
|
|
1640
|
-
if (statusCode && typeof statusCode === 'string') {
|
|
1641
|
-
result.statusCode = statusCode
|
|
1642
|
-
}
|
|
1643
|
-
const headers = this[getArrayItems](object, ns.aml.vocabularies.apiContract.header, objectContext)
|
|
1644
|
-
if (Array.isArray(headers) && headers.length) {
|
|
1645
|
-
result.headers = headers.map((p) => this.parameter(p, objectContext))
|
|
1646
|
-
}
|
|
1647
|
-
const payloads = this[getArrayItems](object, ns.aml.vocabularies.apiContract.payload, objectContext) as
|
|
1648
|
-
| IAmfPayload[]
|
|
1649
|
-
| undefined
|
|
1650
|
-
if (Array.isArray(payloads) && payloads.length) {
|
|
1651
|
-
result.payloads = payloads.map((p) => this.payload(p, objectContext))
|
|
1652
|
-
}
|
|
1653
|
-
const examples = object[
|
|
1654
|
-
this._getAmfKey(ns.aml.vocabularies.apiContract.examples, objectContext) as keyof IAmfResponse
|
|
1655
|
-
] as IAmfExample[] | undefined
|
|
1656
|
-
if (Array.isArray(examples) && examples.length) {
|
|
1657
|
-
result.examples = examples.map((e) => this.example(e, objectContext))
|
|
1658
|
-
}
|
|
1659
|
-
const links = object[this._getAmfKey(ns.aml.vocabularies.apiContract.link, objectContext) as keyof IAmfResponse] as
|
|
1660
|
-
| IAmfTemplatedLink[]
|
|
1661
|
-
| undefined
|
|
1662
|
-
if (Array.isArray(links) && links.length) {
|
|
1663
|
-
result.links = links.map((p) => this.templatedLink(p, objectContext))
|
|
1664
|
-
}
|
|
1665
|
-
return result
|
|
1666
|
-
}
|
|
1667
|
-
|
|
1668
|
-
payload(object: IAmfPayload, context?: Record<string, string>): IApiPayload {
|
|
1669
|
-
const objectContext = context || object['@context']
|
|
1670
|
-
const result: IApiPayload = {
|
|
1671
|
-
id: object['@id'],
|
|
1672
|
-
types: this.readTypes(object['@type'], objectContext),
|
|
1673
|
-
customDomainProperties: this.customDomainProperties(object, objectContext),
|
|
1674
|
-
sourceMaps: this.sourceMap(object, objectContext),
|
|
1675
|
-
examples: [],
|
|
1676
|
-
// encoding: [],
|
|
1677
|
-
}
|
|
1678
|
-
|
|
1679
|
-
const name = this._getValue(object, ns.aml.vocabularies.core.name, objectContext)
|
|
1680
|
-
if (name && typeof name === 'string') {
|
|
1681
|
-
result.name = name
|
|
1682
|
-
}
|
|
1683
|
-
const mediaType = this._getValue(object, ns.aml.vocabularies.core.mediaType, objectContext)
|
|
1684
|
-
if (mediaType && typeof mediaType === 'string') {
|
|
1685
|
-
result.mediaType = mediaType
|
|
1686
|
-
}
|
|
1687
|
-
let schema = object[this._getAmfKey(ns.aml.vocabularies.shapes.schema, objectContext) as keyof IAmfPayload] as
|
|
1688
|
-
| IAmfShape
|
|
1689
|
-
| IAmfShape[]
|
|
1690
|
-
| undefined
|
|
1691
|
-
if (schema) {
|
|
1692
|
-
if (Array.isArray(schema)) {
|
|
1693
|
-
;[schema] = schema
|
|
1694
|
-
}
|
|
1695
|
-
result.schema = this.unknownShape(
|
|
1696
|
-
schema,
|
|
1697
|
-
{
|
|
1698
|
-
trackedId: result.id,
|
|
1699
|
-
},
|
|
1700
|
-
objectContext
|
|
1701
|
-
)
|
|
1702
|
-
}
|
|
1703
|
-
const examples = object[
|
|
1704
|
-
this._getAmfKey(ns.aml.vocabularies.apiContract.examples, objectContext) as keyof IAmfPayload
|
|
1705
|
-
] as IAmfExample[] | undefined
|
|
1706
|
-
if (Array.isArray(examples) && examples.length) {
|
|
1707
|
-
result.examples = examples.map((e) => this.example(e, objectContext))
|
|
1708
|
-
}
|
|
1709
|
-
// if (Array.isArray(encoding) && encoding.length) {
|
|
1710
|
-
// result.encoding = encoding.map((p) => p.id);
|
|
1711
|
-
// }
|
|
1712
|
-
return result
|
|
1713
|
-
}
|
|
1714
|
-
|
|
1715
|
-
templatedLink(object: IAmfTemplatedLink, context?: Record<string, string>): IApiTemplatedLink {
|
|
1716
|
-
const objectContext = context || object['@context']
|
|
1717
|
-
const result: IApiTemplatedLink = {
|
|
1718
|
-
id: object['@id'],
|
|
1719
|
-
types: this.readTypes(object['@type'], objectContext),
|
|
1720
|
-
customDomainProperties: this.customDomainProperties(object, objectContext),
|
|
1721
|
-
sourceMaps: this.sourceMap(object, objectContext),
|
|
1722
|
-
mapping: [],
|
|
1723
|
-
}
|
|
1724
|
-
|
|
1725
|
-
const name = this._getValue(object, ns.aml.vocabularies.core.name, objectContext)
|
|
1726
|
-
if (name && typeof name === 'string') {
|
|
1727
|
-
result.name = name
|
|
1728
|
-
}
|
|
1729
|
-
const description = this._getValue(object, ns.aml.vocabularies.core.description, objectContext)
|
|
1730
|
-
if (description && typeof description === 'string') {
|
|
1731
|
-
result.description = description
|
|
1732
|
-
}
|
|
1733
|
-
const operationId = this._getValue(object, ns.aml.vocabularies.apiContract.operationId, objectContext)
|
|
1734
|
-
if (operationId && typeof operationId === 'string') {
|
|
1735
|
-
result.operationId = operationId
|
|
1736
|
-
}
|
|
1737
|
-
let server = object[
|
|
1738
|
-
this._getAmfKey(ns.aml.vocabularies.apiContract.server, objectContext) as keyof IAmfTemplatedLink
|
|
1739
|
-
] as IAmfServer[] | IAmfServer | undefined
|
|
1740
|
-
if (server) {
|
|
1741
|
-
if (Array.isArray(server)) {
|
|
1742
|
-
;[server] = server
|
|
1743
|
-
}
|
|
1744
|
-
result.server = this.server(server, objectContext)
|
|
1745
|
-
}
|
|
1746
|
-
let mapping = object[
|
|
1747
|
-
this._getAmfKey(ns.aml.vocabularies.apiContract.mapping, objectContext) as keyof IAmfTemplatedLink
|
|
1748
|
-
] as IAmfIriTemplateMapping[] | undefined
|
|
1749
|
-
if (mapping) {
|
|
1750
|
-
if (mapping && !Array.isArray(mapping)) {
|
|
1751
|
-
mapping = [mapping]
|
|
1752
|
-
}
|
|
1753
|
-
if (mapping) {
|
|
1754
|
-
result.mapping = mapping.map((item) => this.iriTemplateMapping(item, objectContext))
|
|
1755
|
-
}
|
|
1756
|
-
}
|
|
1757
|
-
// if (!template.isNullOrEmpty) {
|
|
1758
|
-
// result.template = template.value();
|
|
1759
|
-
// }
|
|
1760
|
-
// if (!requestBody.isNullOrEmpty) {
|
|
1761
|
-
// result.requestBody = requestBody.value();
|
|
1762
|
-
// }
|
|
1763
|
-
return result
|
|
1764
|
-
}
|
|
1765
|
-
|
|
1766
|
-
iriTemplateMapping(object: IAmfIriTemplateMapping, context?: Record<string, string>): IApiIriTemplateMapping {
|
|
1767
|
-
const objectContext = context || object['@context']
|
|
1768
|
-
const result: IApiIriTemplateMapping = {
|
|
1769
|
-
id: object['@id'],
|
|
1770
|
-
types: this.readTypes(object['@type'], objectContext),
|
|
1771
|
-
customDomainProperties: this.customDomainProperties(object, objectContext),
|
|
1772
|
-
sourceMaps: this.sourceMap(object, objectContext),
|
|
1773
|
-
}
|
|
1774
|
-
|
|
1775
|
-
const templateVariable = this._getValue(object, ns.aml.vocabularies.apiContract.templateVariable, objectContext)
|
|
1776
|
-
if (templateVariable && typeof templateVariable === 'string') {
|
|
1777
|
-
result.templateVariable = templateVariable
|
|
1778
|
-
}
|
|
1779
|
-
const linkExpression = this._getValue(object, ns.aml.vocabularies.apiContract.linkExpression, objectContext)
|
|
1780
|
-
if (linkExpression && typeof linkExpression === 'string') {
|
|
1781
|
-
result.linkExpression = linkExpression
|
|
1782
|
-
}
|
|
1783
|
-
return result
|
|
1784
|
-
}
|
|
1785
|
-
|
|
1786
|
-
parametrizedSecurityScheme(
|
|
1787
|
-
object: IAmfParametrizedSecurityScheme,
|
|
1788
|
-
context?: Record<string, string>
|
|
1789
|
-
): IApiParametrizedSecurityScheme {
|
|
1790
|
-
const objectContext = context || object['@context']
|
|
1791
|
-
const result: IApiParametrizedSecurityScheme = {
|
|
1792
|
-
id: object['@id'],
|
|
1793
|
-
types: this.readTypes(object['@type'], objectContext),
|
|
1794
|
-
customDomainProperties: this.customDomainProperties(object, objectContext),
|
|
1795
|
-
sourceMaps: this.sourceMap(object, objectContext),
|
|
1796
|
-
}
|
|
1797
|
-
|
|
1798
|
-
const name = this._getValue(object, ns.aml.vocabularies.core.name, objectContext)
|
|
1799
|
-
if (name && typeof name === 'string') {
|
|
1800
|
-
result.name = name
|
|
1801
|
-
}
|
|
1802
|
-
let scheme = object[
|
|
1803
|
-
this._getAmfKey(ns.aml.vocabularies.security.scheme, objectContext) as keyof IAmfParametrizedSecurityScheme
|
|
1804
|
-
] as IAmfSecurityScheme | IAmfSecurityScheme[] | undefined
|
|
1805
|
-
if (scheme) {
|
|
1806
|
-
if (Array.isArray(scheme)) {
|
|
1807
|
-
;[scheme] = scheme
|
|
1808
|
-
}
|
|
1809
|
-
result.scheme = this.securityScheme(scheme, objectContext)
|
|
1810
|
-
}
|
|
1811
|
-
let settings = object[
|
|
1812
|
-
this._getAmfKey(ns.aml.vocabularies.security.settings, objectContext) as keyof IAmfParametrizedSecurityScheme
|
|
1813
|
-
] as IAmfSettings | IAmfSettings[] | undefined
|
|
1814
|
-
if (settings) {
|
|
1815
|
-
if (Array.isArray(settings)) {
|
|
1816
|
-
;[settings] = settings
|
|
1817
|
-
}
|
|
1818
|
-
result.settings = this.securitySettings(settings, objectContext)
|
|
1819
|
-
}
|
|
1820
|
-
return result
|
|
1821
|
-
}
|
|
1822
|
-
|
|
1823
|
-
securitySchemeListItem(object: IAmfSecurityScheme, context?: Record<string, string>): IApiSecuritySchemeListItem {
|
|
1824
|
-
const objectContext = context || object['@context']
|
|
1825
|
-
|
|
1826
|
-
const result: IApiSecuritySchemeListItem = {
|
|
1827
|
-
id: object['@id'],
|
|
1828
|
-
types: this.readTypes(object['@type'], objectContext),
|
|
1829
|
-
type: '',
|
|
1830
|
-
}
|
|
1831
|
-
|
|
1832
|
-
const type = this._getValue(object, ns.aml.vocabularies.security.type, objectContext)
|
|
1833
|
-
if (type && typeof type === 'string') {
|
|
1834
|
-
result.type = type
|
|
1835
|
-
}
|
|
1836
|
-
const name = this._getValue(object, ns.aml.vocabularies.core.name, objectContext)
|
|
1837
|
-
if (name && typeof name === 'string') {
|
|
1838
|
-
result.name = name
|
|
1839
|
-
}
|
|
1840
|
-
const displayName = this._getValue(object, ns.aml.vocabularies.core.displayName, objectContext)
|
|
1841
|
-
if (displayName && typeof displayName === 'string') {
|
|
1842
|
-
result.displayName = displayName
|
|
1843
|
-
}
|
|
1844
|
-
return result
|
|
1845
|
-
}
|
|
1846
|
-
|
|
1847
|
-
securityScheme(object: IAmfSecurityScheme, context?: Record<string, string>): IApiSecurityScheme {
|
|
1848
|
-
const objectContext = context || object['@context']
|
|
1849
|
-
const result: IApiSecurityScheme = {
|
|
1850
|
-
id: object['@id'],
|
|
1851
|
-
types: this.readTypes(object['@type'], objectContext),
|
|
1852
|
-
customDomainProperties: this.customDomainProperties(object, objectContext),
|
|
1853
|
-
sourceMaps: this.sourceMap(object, objectContext),
|
|
1854
|
-
headers: [],
|
|
1855
|
-
queryParameters: [],
|
|
1856
|
-
responses: [],
|
|
1857
|
-
}
|
|
1858
|
-
|
|
1859
|
-
const name = this._getValue(object, ns.aml.vocabularies.core.name, objectContext)
|
|
1860
|
-
if (name && typeof name === 'string') {
|
|
1861
|
-
result.name = name
|
|
1862
|
-
}
|
|
1863
|
-
const displayName = this._getValue(object, ns.aml.vocabularies.core.displayName, objectContext)
|
|
1864
|
-
if (displayName && typeof displayName === 'string') {
|
|
1865
|
-
result.displayName = displayName
|
|
1866
|
-
}
|
|
1867
|
-
const description = this._getValue(object, ns.aml.vocabularies.core.description, objectContext)
|
|
1868
|
-
if (description && typeof description === 'string') {
|
|
1869
|
-
result.description = description
|
|
1870
|
-
}
|
|
1871
|
-
const type = this._getValue(object, ns.aml.vocabularies.security.type, objectContext)
|
|
1872
|
-
if (type && typeof type === 'string') {
|
|
1873
|
-
result.type = type
|
|
1874
|
-
}
|
|
1875
|
-
let settings = object[
|
|
1876
|
-
this._getAmfKey(ns.aml.vocabularies.security.settings, objectContext) as keyof IAmfSecurityScheme
|
|
1877
|
-
] as IAmfSettings[] | IAmfSettings | undefined
|
|
1878
|
-
if (settings) {
|
|
1879
|
-
if (Array.isArray(settings)) {
|
|
1880
|
-
;[settings] = settings
|
|
1881
|
-
}
|
|
1882
|
-
result.settings = this.securitySettings(settings, objectContext)
|
|
1883
|
-
}
|
|
1884
|
-
let queryString = object[
|
|
1885
|
-
this._getAmfKey(ns.aml.vocabularies.apiContract.queryString, objectContext) as keyof IAmfSecurityScheme
|
|
1886
|
-
] as IAmfShape[] | IAmfShape | undefined
|
|
1887
|
-
if (queryString) {
|
|
1888
|
-
if (Array.isArray(queryString)) {
|
|
1889
|
-
;[queryString] = queryString
|
|
1890
|
-
}
|
|
1891
|
-
result.queryString = this.unknownShape(queryString, undefined, objectContext)
|
|
1892
|
-
}
|
|
1893
|
-
const headers = this[getArrayItems](object, ns.aml.vocabularies.apiContract.header, objectContext)
|
|
1894
|
-
if (Array.isArray(headers) && headers.length) {
|
|
1895
|
-
result.headers = headers.map((p) => this.parameter(p, objectContext))
|
|
1896
|
-
}
|
|
1897
|
-
const queryParameters = this[getArrayItems](object, ns.aml.vocabularies.apiContract.parameter, objectContext)
|
|
1898
|
-
if (Array.isArray(queryParameters) && queryParameters.length) {
|
|
1899
|
-
result.queryParameters = queryParameters.map((p) => this.parameter(p, objectContext))
|
|
1900
|
-
}
|
|
1901
|
-
const responses = this[getArrayItems](object, ns.aml.vocabularies.apiContract.response, objectContext) as
|
|
1902
|
-
| IAmfResponse[]
|
|
1903
|
-
| undefined
|
|
1904
|
-
if (Array.isArray(responses) && responses.length) {
|
|
1905
|
-
result.responses = responses.map((p) => this.response(p, objectContext))
|
|
1906
|
-
}
|
|
1907
|
-
return result
|
|
1908
|
-
}
|
|
1909
|
-
|
|
1910
|
-
securityRequirement(object: IAmfSecurityRequirement, context?: Record<string, string>): IApiSecurityRequirement {
|
|
1911
|
-
const objectContext = context || object['@context']
|
|
1912
|
-
const result: IApiSecurityRequirement = {
|
|
1913
|
-
id: object['@id'],
|
|
1914
|
-
types: this.readTypes(object['@type'], objectContext),
|
|
1915
|
-
customDomainProperties: this.customDomainProperties(object, objectContext),
|
|
1916
|
-
sourceMaps: this.sourceMap(object, objectContext),
|
|
1917
|
-
schemes: [],
|
|
1918
|
-
}
|
|
1919
|
-
|
|
1920
|
-
const name = this._getValue(object, ns.aml.vocabularies.core.name, objectContext)
|
|
1921
|
-
if (name && typeof name === 'string') {
|
|
1922
|
-
result.name = name
|
|
1923
|
-
}
|
|
1924
|
-
const schemes = object[
|
|
1925
|
-
this._getAmfKey(ns.aml.vocabularies.security.schemes, objectContext) as keyof IAmfSecurityRequirement
|
|
1926
|
-
] as IAmfParametrizedSecurityScheme[] | undefined
|
|
1927
|
-
if (Array.isArray(schemes) && schemes.length) {
|
|
1928
|
-
result.schemes = schemes.map((p) => this.parametrizedSecurityScheme(p, objectContext))
|
|
1929
|
-
}
|
|
1930
|
-
return result
|
|
1931
|
-
}
|
|
1932
|
-
|
|
1933
|
-
securitySettings(object: IAmfSettings, context?: Record<string, string>): IApiSecuritySettingsUnion {
|
|
1934
|
-
const objectContext = context || object['@context']
|
|
1935
|
-
const types = this.readTypes(object['@type'], objectContext)
|
|
1936
|
-
if (types.includes(ns.aml.vocabularies.security.OAuth1Settings)) {
|
|
1937
|
-
return this.oAuth1Settings(object as IAmfOAuth1Settings, objectContext)
|
|
1938
|
-
}
|
|
1939
|
-
if (types.includes(ns.aml.vocabularies.security.OAuth2Settings)) {
|
|
1940
|
-
return this.oAuth2Settings(object as IAmfOAuth2Settings, objectContext)
|
|
1941
|
-
}
|
|
1942
|
-
if (types.includes(ns.aml.vocabularies.security.ApiKeySettings)) {
|
|
1943
|
-
return this.apiKeySettings(object as IAmfApiKeySettings, objectContext)
|
|
1944
|
-
}
|
|
1945
|
-
if (types.includes(ns.aml.vocabularies.security.HttpSettings)) {
|
|
1946
|
-
return this.httpSettings(object as IAmfHttpSettings, objectContext)
|
|
1947
|
-
}
|
|
1948
|
-
if (types.includes(ns.aml.vocabularies.security.OpenIdConnectSettings)) {
|
|
1949
|
-
return this.openIdConnectSettings(object as IAmfOpenIdConnectSettings, objectContext)
|
|
1950
|
-
}
|
|
1951
|
-
return this.settings(object, objectContext)
|
|
1952
|
-
}
|
|
1953
|
-
|
|
1954
|
-
/**
|
|
1955
|
-
* @param {IAmfSettings} object
|
|
1956
|
-
* @param context
|
|
1957
|
-
* @returns {IApiSecuritySettings}
|
|
1958
|
-
*/
|
|
1959
|
-
settings(object: IAmfSettings, context?: Record<string, string>): IApiSecuritySettings {
|
|
1960
|
-
const objectContext = context || object['@context']
|
|
1961
|
-
const result: IApiSecuritySettings = {
|
|
1962
|
-
id: object['@id'],
|
|
1963
|
-
types: this.readTypes(object['@type'], objectContext),
|
|
1964
|
-
customDomainProperties: this.customDomainProperties(object, objectContext),
|
|
1965
|
-
sourceMaps: this.sourceMap(object, objectContext),
|
|
1966
|
-
}
|
|
1967
|
-
// if (additionalProperties && additionalProperties.id) {
|
|
1968
|
-
// result.additionalProperties = this.unknownDataNode(additionalProperties);
|
|
1969
|
-
// }
|
|
1970
|
-
return result
|
|
1971
|
-
}
|
|
1972
|
-
|
|
1973
|
-
oAuth1Settings(object: IAmfOAuth1Settings, context?: Record<string, string>): IApiSecurityOAuth1Settings {
|
|
1974
|
-
const objectContext = context || object['@context']
|
|
1975
|
-
const result = this.settings(object, objectContext) as IApiSecurityOAuth1Settings
|
|
1976
|
-
|
|
1977
|
-
const authorizationUri = this._getValue(object, ns.aml.vocabularies.security.authorizationUri, objectContext)
|
|
1978
|
-
if (authorizationUri && typeof authorizationUri === 'string') {
|
|
1979
|
-
result.authorizationUri = authorizationUri
|
|
1980
|
-
}
|
|
1981
|
-
const requestTokenUri = this._getValue(object, ns.aml.vocabularies.security.requestTokenUri, objectContext)
|
|
1982
|
-
if (requestTokenUri && typeof requestTokenUri === 'string') {
|
|
1983
|
-
result.requestTokenUri = requestTokenUri
|
|
1984
|
-
}
|
|
1985
|
-
const tokenCredentialsUri = this._getValue(object, ns.aml.vocabularies.security.tokenCredentialsUri, objectContext)
|
|
1986
|
-
if (tokenCredentialsUri && typeof tokenCredentialsUri === 'string') {
|
|
1987
|
-
result.tokenCredentialsUri = tokenCredentialsUri
|
|
1988
|
-
}
|
|
1989
|
-
const signatures = this._getValueArray(object, ns.aml.vocabularies.security.signature, objectContext) as string[]
|
|
1990
|
-
if (Array.isArray(signatures) && signatures.length) {
|
|
1991
|
-
result.signatures = signatures
|
|
1992
|
-
} else {
|
|
1993
|
-
result.signatures = []
|
|
1994
|
-
}
|
|
1995
|
-
return result
|
|
1996
|
-
}
|
|
1997
|
-
|
|
1998
|
-
oAuth2Settings(object: IAmfOAuth2Settings, context?: Record<string, string>): IApiSecurityOAuth2Settings {
|
|
1999
|
-
const objectContext = context || object['@context']
|
|
2000
|
-
const result = this.settings(object, objectContext) as IApiSecurityOAuth2Settings
|
|
2001
|
-
|
|
2002
|
-
const grants = this._getValueArray(
|
|
2003
|
-
object,
|
|
2004
|
-
ns.aml.vocabularies.security.authorizationGrant,
|
|
2005
|
-
objectContext
|
|
2006
|
-
) as string[]
|
|
2007
|
-
if (Array.isArray(grants) && grants.length) {
|
|
2008
|
-
result.authorizationGrants = grants
|
|
2009
|
-
} else {
|
|
2010
|
-
result.authorizationGrants = []
|
|
2011
|
-
}
|
|
2012
|
-
const flows = object[
|
|
2013
|
-
this._getAmfKey(ns.aml.vocabularies.security.flows, objectContext) as keyof IAmfOAuth2Settings
|
|
2014
|
-
] as IAmfOAuth2Flow[] | undefined
|
|
2015
|
-
if (Array.isArray(flows) && flows.length) {
|
|
2016
|
-
result.flows = flows.map((p) => this.oAuth2Flow(p, objectContext))
|
|
2017
|
-
} else {
|
|
2018
|
-
result.flows = []
|
|
2019
|
-
}
|
|
2020
|
-
return result
|
|
2021
|
-
}
|
|
2022
|
-
|
|
2023
|
-
oAuth2Flow(object: IAmfOAuth2Flow, context?: Record<string, string>): IApiSecurityOAuth2Flow {
|
|
2024
|
-
const objectContext = context || object['@context']
|
|
2025
|
-
const result: IApiSecurityOAuth2Flow = {
|
|
2026
|
-
id: object['@id'],
|
|
2027
|
-
types: this.readTypes(object['@type'], objectContext),
|
|
2028
|
-
customDomainProperties: this.customDomainProperties(object, objectContext),
|
|
2029
|
-
scopes: [],
|
|
2030
|
-
sourceMaps: this.sourceMap(object, objectContext),
|
|
2031
|
-
}
|
|
2032
|
-
|
|
2033
|
-
const authorizationUri = this._getValue(object, ns.aml.vocabularies.security.authorizationUri, objectContext)
|
|
2034
|
-
if (authorizationUri && typeof authorizationUri === 'string') {
|
|
2035
|
-
result.authorizationUri = authorizationUri
|
|
2036
|
-
}
|
|
2037
|
-
const accessTokenUri = this._getValue(object, ns.aml.vocabularies.security.accessTokenUri, objectContext)
|
|
2038
|
-
if (accessTokenUri && typeof accessTokenUri === 'string') {
|
|
2039
|
-
result.accessTokenUri = accessTokenUri
|
|
2040
|
-
}
|
|
2041
|
-
const flow = this._getValue(object, ns.aml.vocabularies.security.flow, objectContext)
|
|
2042
|
-
if (flow && typeof flow === 'string') {
|
|
2043
|
-
result.flow = flow
|
|
2044
|
-
}
|
|
2045
|
-
const refreshUri = this._getValue(object, ns.aml.vocabularies.security.refreshUri, objectContext)
|
|
2046
|
-
if (refreshUri && typeof refreshUri === 'string') {
|
|
2047
|
-
result.refreshUri = refreshUri
|
|
2048
|
-
}
|
|
2049
|
-
const scopes = object[
|
|
2050
|
-
this._getAmfKey(ns.aml.vocabularies.security.scope, objectContext) as keyof IAmfOAuth2Flow
|
|
2051
|
-
] as IAmfScope[] | undefined
|
|
2052
|
-
if (Array.isArray(scopes) && scopes.length) {
|
|
2053
|
-
result.scopes = scopes.map((p) => this.scope(p, objectContext))
|
|
2054
|
-
}
|
|
2055
|
-
return result
|
|
2056
|
-
}
|
|
2057
|
-
|
|
2058
|
-
scope(object: IAmfScope, context?: Record<string, string>): IApiSecurityScope {
|
|
2059
|
-
const objectContext = context || object['@context']
|
|
2060
|
-
const result: IApiSecurityScope = {
|
|
2061
|
-
id: object['@id'],
|
|
2062
|
-
types: this.readTypes(object['@type'], objectContext),
|
|
2063
|
-
customDomainProperties: this.customDomainProperties(object, objectContext),
|
|
2064
|
-
sourceMaps: this.sourceMap(object, objectContext),
|
|
2065
|
-
}
|
|
2066
|
-
|
|
2067
|
-
const name = this._getValue(object, ns.aml.vocabularies.core.name, objectContext)
|
|
2068
|
-
if (name && typeof name === 'string') {
|
|
2069
|
-
result.name = name
|
|
2070
|
-
}
|
|
2071
|
-
const description = this._getValue(object, ns.aml.vocabularies.core.description, objectContext)
|
|
2072
|
-
if (description && typeof description === 'string') {
|
|
2073
|
-
result.description = description
|
|
2074
|
-
}
|
|
2075
|
-
return result
|
|
2076
|
-
}
|
|
2077
|
-
|
|
2078
|
-
apiKeySettings(object: IAmfApiKeySettings, context?: Record<string, string>): IApiSecurityApiKeySettings {
|
|
2079
|
-
const objectContext = context || object['@context']
|
|
2080
|
-
const result = this.settings(object, objectContext) as IApiSecurityApiKeySettings
|
|
2081
|
-
|
|
2082
|
-
const name = this._getValue(object, ns.aml.vocabularies.core.name, objectContext)
|
|
2083
|
-
if (name && typeof name === 'string') {
|
|
2084
|
-
result.name = name
|
|
2085
|
-
}
|
|
2086
|
-
const inParam = this._getValue(object, ns.aml.vocabularies.security.in, objectContext)
|
|
2087
|
-
if (inParam && typeof inParam === 'string') {
|
|
2088
|
-
result.in = inParam
|
|
2089
|
-
}
|
|
2090
|
-
return result
|
|
2091
|
-
}
|
|
2092
|
-
|
|
2093
|
-
httpSettings(object: IAmfHttpSettings, context?: Record<string, string>): IApiSecurityHttpSettings {
|
|
2094
|
-
const objectContext = context || object['@context']
|
|
2095
|
-
const result = this.settings(object, objectContext) as IApiSecurityHttpSettings
|
|
2096
|
-
|
|
2097
|
-
const scheme = this._getValue(object, ns.aml.vocabularies.security.scheme, objectContext)
|
|
2098
|
-
if (scheme && typeof scheme === 'string') {
|
|
2099
|
-
result.scheme = scheme
|
|
2100
|
-
}
|
|
2101
|
-
const bearerFormat = this._getValue(object, ns.aml.vocabularies.security.bearerFormat, objectContext)
|
|
2102
|
-
if (bearerFormat && typeof bearerFormat === 'string') {
|
|
2103
|
-
result.bearerFormat = bearerFormat
|
|
2104
|
-
}
|
|
2105
|
-
return result
|
|
2106
|
-
}
|
|
2107
|
-
|
|
2108
|
-
openIdConnectSettings(
|
|
2109
|
-
object: IAmfOpenIdConnectSettings,
|
|
2110
|
-
context?: Record<string, string>
|
|
2111
|
-
): IApiSecurityOpenIdConnectSettings {
|
|
2112
|
-
const objectContext = context || object['@context']
|
|
2113
|
-
const result = this.settings(object, objectContext) as IApiSecurityOpenIdConnectSettings
|
|
2114
|
-
|
|
2115
|
-
const url = this._getValue(object, ns.aml.vocabularies.security.openIdConnectUrl, objectContext)
|
|
2116
|
-
if (url && typeof url === 'string') {
|
|
2117
|
-
result.url = url
|
|
2118
|
-
}
|
|
2119
|
-
return result
|
|
2120
|
-
}
|
|
2121
|
-
|
|
2122
|
-
/**
|
|
2123
|
-
* Serializes source maps, when available.
|
|
2124
|
-
*/
|
|
2125
|
-
sourceMap(object: IAmfDocumentSourceMaps, context?: Record<string, string>): IApiDocumentSourceMaps | undefined {
|
|
2126
|
-
const objectContext = context || object['@context']
|
|
2127
|
-
let sm = object[
|
|
2128
|
-
this._getAmfKey(ns.aml.vocabularies.docSourceMaps.sources, objectContext) as keyof IAmfDocumentSourceMaps
|
|
2129
|
-
] as IAmfDocumentSourceMaps[] | IAmfDocumentSourceMaps | undefined
|
|
2130
|
-
if (!sm) {
|
|
2131
|
-
return undefined
|
|
2132
|
-
}
|
|
2133
|
-
if (Array.isArray(sm)) {
|
|
2134
|
-
;[sm] = sm
|
|
2135
|
-
}
|
|
2136
|
-
const result: IApiDocumentSourceMaps = {
|
|
2137
|
-
id: sm['@id'],
|
|
2138
|
-
types: this.readTypes(sm['@type']),
|
|
2139
|
-
}
|
|
2140
|
-
const synthesizedField = sm[
|
|
2141
|
-
this._getAmfKey(ns.aml.vocabularies.docSourceMaps.synthesizedField, objectContext) as keyof IAmfDocumentSourceMaps
|
|
2142
|
-
] as IAmfSynthesizedField[] | undefined
|
|
2143
|
-
if (Array.isArray(synthesizedField) && synthesizedField.length) {
|
|
2144
|
-
result.synthesizedField = synthesizedField.map((i) => this.synthesizedField(i, objectContext))
|
|
2145
|
-
}
|
|
2146
|
-
const lexical = sm[
|
|
2147
|
-
this._getAmfKey(ns.aml.vocabularies.docSourceMaps.lexical, objectContext) as keyof IAmfDocumentSourceMaps
|
|
2148
|
-
] as IAmfSynthesizedField[] | undefined
|
|
2149
|
-
if (Array.isArray(lexical) && lexical.length) {
|
|
2150
|
-
result.lexical = lexical.map((i) => this.synthesizedField(i, objectContext))
|
|
2151
|
-
}
|
|
2152
|
-
const trackedElement = sm[
|
|
2153
|
-
this._getAmfKey(ns.aml.vocabularies.docSourceMaps.trackedElement, objectContext) as keyof IAmfDocumentSourceMaps
|
|
2154
|
-
] as IAmfSynthesizedField[] | undefined
|
|
2155
|
-
if (Array.isArray(trackedElement) && trackedElement.length) {
|
|
2156
|
-
result.trackedElement = this.synthesizedField(trackedElement[0], objectContext)
|
|
2157
|
-
}
|
|
2158
|
-
const autoName = sm[
|
|
2159
|
-
this._getAmfKey(
|
|
2160
|
-
ns.aml.vocabularies.docSourceMaps.autoGeneratedName,
|
|
2161
|
-
objectContext
|
|
2162
|
-
) as keyof IAmfDocumentSourceMaps
|
|
2163
|
-
] as IAmfSynthesizedField[] | undefined
|
|
2164
|
-
if (Array.isArray(autoName) && autoName.length) {
|
|
2165
|
-
result.autoGeneratedName = autoName.map((i) => this.synthesizedField(i, objectContext))
|
|
2166
|
-
}
|
|
2167
|
-
const jsonSchema = sm[
|
|
2168
|
-
this._getAmfKey(ns.aml.vocabularies.docSourceMaps.parsedJsonSchema, objectContext) as keyof IAmfDocumentSourceMaps
|
|
2169
|
-
] as IAmfSynthesizedField[] | undefined
|
|
2170
|
-
if (Array.isArray(jsonSchema) && jsonSchema.length) {
|
|
2171
|
-
result.parsedJsonSchema = this.synthesizedField(jsonSchema[0], objectContext)
|
|
2172
|
-
}
|
|
2173
|
-
const declaredElement = sm[
|
|
2174
|
-
this._getAmfKey(ns.aml.vocabularies.docSourceMaps.declaredElement, objectContext) as keyof IAmfDocumentSourceMaps
|
|
2175
|
-
] as IAmfSynthesizedField[] | undefined
|
|
2176
|
-
if (Array.isArray(declaredElement) && declaredElement.length) {
|
|
2177
|
-
result.declaredElement = this.synthesizedField(declaredElement[0], objectContext)
|
|
2178
|
-
}
|
|
2179
|
-
return result
|
|
2180
|
-
}
|
|
2181
|
-
|
|
2182
|
-
synthesizedField(object: IAmfSynthesizedField, context?: Record<string, string>): IApiSynthesizedField {
|
|
2183
|
-
// compact model
|
|
2184
|
-
if (typeof object === 'string') {
|
|
2185
|
-
return {
|
|
2186
|
-
id: 'synthesizedField/generated',
|
|
2187
|
-
value: object,
|
|
2188
|
-
} as IApiSynthesizedField
|
|
2189
|
-
}
|
|
2190
|
-
const result: IApiSynthesizedField = {
|
|
2191
|
-
id: object['@id'],
|
|
2192
|
-
value: '',
|
|
2193
|
-
}
|
|
2194
|
-
const element = this._getValue(object as IAmfDomainElement, ns.aml.vocabularies.docSourceMaps.element, context) as
|
|
2195
|
-
| string
|
|
2196
|
-
| undefined
|
|
2197
|
-
if (typeof element === 'string') {
|
|
2198
|
-
result.element = element
|
|
2199
|
-
}
|
|
2200
|
-
const value = this._getValue(object as IAmfDomainElement, ns.aml.vocabularies.docSourceMaps.value, context) as
|
|
2201
|
-
| string
|
|
2202
|
-
| undefined
|
|
2203
|
-
if (typeof value === 'string') {
|
|
2204
|
-
result.value = value
|
|
2205
|
-
}
|
|
2206
|
-
return result
|
|
2207
|
-
}
|
|
2208
|
-
|
|
2209
|
-
parametrizedDeclaration(
|
|
2210
|
-
object: IAmfParametrizedDeclaration,
|
|
2211
|
-
context?: Record<string, string>
|
|
2212
|
-
): IApiParametrizedDeclaration {
|
|
2213
|
-
const objectContext = context || object['@context']
|
|
2214
|
-
const result: IApiParametrizedDeclaration = {
|
|
2215
|
-
id: object['@id'],
|
|
2216
|
-
types: this.readTypes(object['@type'], objectContext),
|
|
2217
|
-
variables: [],
|
|
2218
|
-
customDomainProperties: this.customDomainProperties(object, objectContext),
|
|
2219
|
-
sourceMaps: this.sourceMap(object, objectContext),
|
|
2220
|
-
}
|
|
2221
|
-
|
|
2222
|
-
const name = this._getValue(object, ns.aml.vocabularies.core.name, objectContext)
|
|
2223
|
-
if (name && typeof name === 'string') {
|
|
2224
|
-
result.name = name
|
|
2225
|
-
}
|
|
2226
|
-
const variables = object[
|
|
2227
|
-
this._getAmfKey(ns.aml.vocabularies.document.variable, objectContext) as keyof IAmfParametrizedDeclaration
|
|
2228
|
-
] as IAmfVariableValue[] | undefined
|
|
2229
|
-
if (Array.isArray(variables)) {
|
|
2230
|
-
variables.forEach((item) => {
|
|
2231
|
-
result.variables.push(this.variableValue(item, objectContext))
|
|
2232
|
-
})
|
|
2233
|
-
}
|
|
2234
|
-
const targets = object[
|
|
2235
|
-
this._getAmfKey(ns.aml.vocabularies.document.target, objectContext) as keyof IAmfParametrizedDeclaration
|
|
2236
|
-
] as IAmfAbstractDeclaration[] | undefined
|
|
2237
|
-
if (Array.isArray(targets) && targets.length) {
|
|
2238
|
-
const [target] = targets
|
|
2239
|
-
result.target = this.abstractDeclaration(target, objectContext)
|
|
2240
|
-
}
|
|
2241
|
-
return result
|
|
2242
|
-
}
|
|
2243
|
-
|
|
2244
|
-
parametrizedTrait(object: IAmfParametrizedTrait, context?: Record<string, string>): IApiParametrizedTrait {
|
|
2245
|
-
const objectContext = context || object['@context']
|
|
2246
|
-
const result = this.parametrizedDeclaration(object, objectContext) as IApiParametrizedTrait
|
|
2247
|
-
return result
|
|
2248
|
-
}
|
|
2249
|
-
|
|
2250
|
-
parametrizedResourceType(
|
|
2251
|
-
object: IAmfParametrizedResourceType,
|
|
2252
|
-
context?: Record<string, string>
|
|
2253
|
-
): IApiParametrizedResourceType {
|
|
2254
|
-
const objectContext = context || object['@context']
|
|
2255
|
-
const result = this.parametrizedDeclaration(object, objectContext) as IApiParametrizedResourceType
|
|
2256
|
-
return result
|
|
2257
|
-
}
|
|
2258
|
-
|
|
2259
|
-
variableValue(object: IAmfVariableValue, context?: Record<string, string>): IApiVariableValue {
|
|
2260
|
-
const objectContext = context || object['@context']
|
|
2261
|
-
|
|
2262
|
-
const name = this._getValue(object, ns.aml.vocabularies.core.name, objectContext) as string
|
|
2263
|
-
const result: IApiVariableValue = {
|
|
2264
|
-
id: object['@id'],
|
|
2265
|
-
types: this.readTypes(object['@type'], objectContext),
|
|
2266
|
-
customDomainProperties: this.customDomainProperties(object, objectContext),
|
|
2267
|
-
sourceMaps: this.sourceMap(object, objectContext),
|
|
2268
|
-
name,
|
|
2269
|
-
}
|
|
2270
|
-
const values = object[
|
|
2271
|
-
this._getAmfKey(ns.aml.vocabularies.document.value, objectContext) as keyof IAmfVariableValue
|
|
2272
|
-
] as IAmfDataNode[] | undefined
|
|
2273
|
-
if (Array.isArray(values)) {
|
|
2274
|
-
const [item] = values
|
|
2275
|
-
result.value = this.unknownDataNode(item, objectContext)
|
|
2276
|
-
}
|
|
2277
|
-
return result
|
|
2278
|
-
}
|
|
2279
|
-
|
|
2280
|
-
abstractDeclaration(object: IAmfAbstractDeclaration, context?: Record<string, string>): IApiAbstractDeclaration {
|
|
2281
|
-
const objectContext = context || object['@context']
|
|
2282
|
-
|
|
2283
|
-
const name = this._getValue(object, ns.aml.vocabularies.core.name, objectContext) as string
|
|
2284
|
-
const result: IApiAbstractDeclaration = {
|
|
2285
|
-
id: object['@id'],
|
|
2286
|
-
types: this.readTypes(object['@type'], objectContext),
|
|
2287
|
-
customDomainProperties: this.customDomainProperties(object, objectContext),
|
|
2288
|
-
sourceMaps: this.sourceMap(object, objectContext),
|
|
2289
|
-
name,
|
|
2290
|
-
variables: [],
|
|
2291
|
-
}
|
|
2292
|
-
const variables = this._getValueArray(object, ns.aml.vocabularies.document.variable, objectContext) as string[]
|
|
2293
|
-
if (Array.isArray(variables)) {
|
|
2294
|
-
result.variables = variables
|
|
2295
|
-
}
|
|
2296
|
-
const description = this._getValue(object, ns.aml.vocabularies.core.description, objectContext)
|
|
2297
|
-
if (description && typeof description === 'string') {
|
|
2298
|
-
result.description = description
|
|
2299
|
-
}
|
|
2300
|
-
const dataNode = object[
|
|
2301
|
-
this._getAmfKey(ns.aml.vocabularies.document.dataNode, objectContext) as keyof IAmfAbstractDeclaration
|
|
2302
|
-
] as IAmfDataNode[] | undefined
|
|
2303
|
-
if (Array.isArray(dataNode)) {
|
|
2304
|
-
const [item] = dataNode
|
|
2305
|
-
result.dataNode = this.unknownDataNode(item, objectContext)
|
|
2306
|
-
}
|
|
2307
|
-
return result
|
|
2308
|
-
}
|
|
2309
|
-
|
|
2310
|
-
/**
|
|
2311
|
-
* @param object The EndPoint to serialize as a list item.
|
|
2312
|
-
* @returns Serialized EndPoint as a list item.
|
|
2313
|
-
*/
|
|
2314
|
-
endPointWithOperationsListItem(
|
|
2315
|
-
object: IAmfEndPoint,
|
|
2316
|
-
context?: Record<string, string>
|
|
2317
|
-
): IApiEndPointWithOperationsListItem {
|
|
2318
|
-
const path = this._getValue(object, ns.aml.vocabularies.apiContract.path, context) as string
|
|
2319
|
-
const result: IApiEndPointWithOperationsListItem = {
|
|
2320
|
-
id: object['@id'],
|
|
2321
|
-
path,
|
|
2322
|
-
operations: [],
|
|
2323
|
-
}
|
|
2324
|
-
const operations = this[getArrayItems](object, ns.aml.vocabularies.apiContract.supportedOperation, context) as
|
|
2325
|
-
| IAmfOperation[]
|
|
2326
|
-
| undefined
|
|
2327
|
-
if (Array.isArray(operations) && operations.length) {
|
|
2328
|
-
result.operations = operations.map((i) => this.operationListItem(i, context))
|
|
2329
|
-
}
|
|
2330
|
-
const name = this._getValue(object, ns.aml.vocabularies.core.name, context)
|
|
2331
|
-
if (name && typeof name === 'string') {
|
|
2332
|
-
result.name = name
|
|
2333
|
-
}
|
|
2334
|
-
return result
|
|
2335
|
-
}
|
|
2336
|
-
|
|
2337
|
-
/**
|
|
2338
|
-
* @param object The Operation to serialize as a list item.
|
|
2339
|
-
* @param context A context to use. If not set, it looks for the context of the passed model
|
|
2340
|
-
* @returns Serialized Operation as a list item.
|
|
2341
|
-
*/
|
|
2342
|
-
operationListItem(object: IAmfOperation, context?: Record<string, string>): IApiOperationListItem {
|
|
2343
|
-
const result: IApiOperationListItem = {
|
|
2344
|
-
id: object['@id'],
|
|
2345
|
-
method: '',
|
|
2346
|
-
}
|
|
2347
|
-
|
|
2348
|
-
const method = this._getValue(object, ns.aml.vocabularies.apiContract.method, context)
|
|
2349
|
-
if (method && typeof method === 'string') {
|
|
2350
|
-
result.method = method
|
|
2351
|
-
}
|
|
2352
|
-
const name = this._getValue(object, ns.aml.vocabularies.core.name, context)
|
|
2353
|
-
if (name && typeof name === 'string') {
|
|
2354
|
-
result.name = name
|
|
2355
|
-
}
|
|
2356
|
-
return result
|
|
2357
|
-
}
|
|
2358
|
-
}
|