Skip to content

Commit c5ca04d

Browse files
authored
Merge pull request #48 from advanced-rest-client/fix/W-11084386/xml-namespace
fix: missing namespace in xml tags
2 parents dec50f7 + 208d37e commit c5ca04d

File tree

11 files changed

+213
-63
lines changed

11 files changed

+213
-63
lines changed

demo/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ class ComponentDemo extends ApiDemoPage {
122122
['APIC-487', 'APIC-487'],
123123
['APIC-391', 'APIC-391'],
124124
['APIC-655', 'APIC-655'],
125+
['xml-api', 'xml-api'],
125126
].map(
126127
([file, label]) => html`
127128
<anypoint-item data-src="${file}-compact.json"

demo/model.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,6 @@ files.set('10732397/10732397.raml', { type: 'RAML 1.0' });
2525
files.set('oas-3-api/oas-3-api.yaml', { type: 'OAS 3.0', mime: 'application/yaml' });
2626
files.set('allof-types/allof-types.yaml', { type: 'OAS 3.0', mime: 'application/yaml' });
2727
files.set('APIC-679/APIC-679.yaml', { type: 'OAS 3.0', mime: 'application/yaml' });
28+
files.set('xml-api/xml-api.yaml', { type: 'OAS 3.0', mime: 'application/yaml' });
2829

2930
generator.generate(files);

demo/xml-api/xml-api.yaml

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
openapi: 3.0.0
2+
info:
3+
title: OPTY Nexus To SFDC Rest Service
4+
description: >-
5+
This API serves incoming request to process data to Create or Update the
6+
OPTY data.
7+
version: v1.0
8+
paths:
9+
/OPTYNexus:
10+
post:
11+
description: This api process data Create or Update OPTY from OPTY Nexus To LSG SFDC.
12+
requestBody:
13+
content:
14+
application/json:
15+
schema:
16+
$ref: '#/components/schemas/nexusInputMessage'
17+
application/xml:
18+
schema:
19+
$ref: '#/components/schemas/nexusInputMessage'
20+
responses:
21+
'200':
22+
description: Successful
23+
content:
24+
application/json:
25+
schema:
26+
$ref: '#/components/schemas/nexusOutputMessage'
27+
application/xml:
28+
schema:
29+
$ref: '#/components/schemas/nexusOutputMessage'
30+
31+
components:
32+
schemas:
33+
nexusInputMessage:
34+
description: Input Message Type
35+
type: object
36+
xml:
37+
namespace: http://xmlns.oracle.com/CSAAS/OPTYNexusToSFDCBPELProcess/Schema
38+
prefix: t0
39+
name: nexusInputMessage
40+
additionalProperties: false
41+
required:
42+
- nexusInputType
43+
properties:
44+
nexusInputType:
45+
type: array
46+
xml:
47+
prefix: t0
48+
name: nexusInputType
49+
items:
50+
type: object
51+
required:
52+
- Primary_Contact_c
53+
additionalProperties: false
54+
properties:
55+
Primary_Contact_c:
56+
description: Primary_Contact_c
57+
example: "0031U00001ykLV7QAM"
58+
type: string
59+
xml:
60+
prefix: t0
61+
name: Primary_Contact_c
62+
63+
nexusOutputMessage:
64+
description: Output Response Type
65+
type: object
66+
required:
67+
- salesforce_id
68+
additionalProperties: false
69+
properties:
70+
salesforce_id:
71+
description: salesforce_id
72+
example: "0061U00000SHSfMQAX"
73+
type: string
74+
xml:
75+
name: salesforce_id
76+
77+
servers:
78+
- description: Oracle SOA Test Url
79+
url: http://test-ofmcsaas.amer.thermo.com/soa-infra/resources/CRM/OPTYNexusToSFDC!1.0/OPTYNexusToSFDCRestService

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@api-components/api-example-generator",
33
"description": "Examples generator from AMF model",
4-
"version": "4.4.16",
4+
"version": "4.4.17",
55
"license": "Apache-2.0",
66
"main": "index.js",
77
"module": "index.js",

src/ApiExampleGenerator.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,10 @@ export class ApiExampleGenerator extends LitElement {
211211
return this._generator._processDataObjectProperties(doc, node, property);
212212
}
213213

214+
_computeXmlSerializationData(serialization) {
215+
return this._generator._computeXmlSerializationData(serialization);
216+
}
217+
214218
_dataNameFromKey(key) {
215219
return dataNameFromKey(key);
216220
}

src/ExampleGenerator.d.ts

Lines changed: 39 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,12 @@ declare class ExampleGenerator extends AmfHelperMixin(Object) {
9696
/**
9797
* The AMF model.
9898
*/
99-
amf: Array<object>|object;
99+
amf: Array<object> | object;
100100

101101
/**
102102
* @param amf The AMF model.
103103
*/
104-
constructor(amf?: Array<object>|object);
104+
constructor(amf?: Array<object> | object);
105105

106106
/**
107107
* Lists media types names for payloads.
@@ -112,7 +112,7 @@ declare class ExampleGenerator extends AmfHelperMixin(Object) {
112112
* @returns Returns a list of mime types or undefined
113113
* if not found.
114114
*/
115-
listMedia(payloads: Array<object>|object): string[]|undefined;
115+
listMedia(payloads: Array<object> | object): string[] | undefined;
116116

117117
/**
118118
* Generates a list of examples from an AMF Payloads array for a given media type.
@@ -125,7 +125,7 @@ declare class ExampleGenerator extends AmfHelperMixin(Object) {
125125
* @param media A media to for which to generate the examples.
126126
* @returns Example value.
127127
*/
128-
generatePayloadsExamples(payloads: Array<object>|object, media: String, opts?: ExampleOptions): Array<Example>|undefined;
128+
generatePayloadsExamples(payloads: Array<object> | object, media: String, opts?: ExampleOptions): Array<Example> | undefined;
129129

130130
/**
131131
* Generates a list of examples for a single AMF Payload shape.
@@ -134,7 +134,7 @@ declare class ExampleGenerator extends AmfHelperMixin(Object) {
134134
* @param mime A mime type to use.
135135
* @returns List of examples.
136136
*/
137-
generatePayloadExamples(payload: object, mime: String, opts?: ExampleOptions): Array<Example>|undefined;
137+
generatePayloadExamples(payload: object, mime: String, opts?: ExampleOptions): Array<Example> | undefined;
138138

139139
/**
140140
* Computes examples from an AMF shape.
@@ -149,15 +149,15 @@ declare class ExampleGenerator extends AmfHelperMixin(Object) {
149149
* Besides that, `opts.typeId` is required to compute examples for a payload.
150150
* The `typeId` is a value of `@id` of the Payload shape.
151151
*/
152-
computeExamples(schema: object, mime: String, opts?: ExampleOptions): Example[]|undefined;
152+
computeExamples(schema: object, mime: String, opts?: ExampleOptions): Example[] | undefined;
153153

154154
/**
155155
* Reads a raw value of JSON schema if available.
156156
*
157157
* @param schema Schema shape of a type.
158158
* @returns JSON schema if exists.
159159
*/
160-
_readJsonSchema(schema: object): String|undefined;
160+
_readJsonSchema(schema: object): String | undefined;
161161

162162
/**
163163
* Computes examples value from a list of examples.
@@ -169,7 +169,7 @@ declare class ExampleGenerator extends AmfHelperMixin(Object) {
169169
* Besides that, `opts.typeId` is required to compute examples for a payload.
170170
* The `typeId` is a value of `@id` of the Payload shape.
171171
*/
172-
_computeFromExamples(examples: Array<object>, mime: String, opts?: object): Array<object>|undefined;
172+
_computeFromExamples(examples: Array<object>, mime: String, opts?: object): Array<object> | undefined;
173173

174174
/**
175175
* In AMF 4 the examples model changes from being an array of examples
@@ -182,15 +182,15 @@ declare class ExampleGenerator extends AmfHelperMixin(Object) {
182182
* @param examples Examples model.
183183
* @returns List of examples to process.
184184
*/
185-
_processExamples(examples: object[]|object): any[]|undefined;
185+
_processExamples(examples: object[] | object): any[] | undefined;
186186

187187
/**
188188
* Uses Example shape's source maps to determine which examples should be rendered.
189189
*
190190
* @param examples List of AMF Example shapes.
191191
* @param typeId Payload ID
192192
*/
193-
_listTypeExamples(examples: Array<object>, typeId: String): Array<object>|undefined;
193+
_listTypeExamples(examples: Array<object>, typeId: String): Array<object> | undefined;
194194

195195
/**
196196
* Generate an example from an example shape.
@@ -199,15 +199,15 @@ declare class ExampleGenerator extends AmfHelperMixin(Object) {
199199
* @param mime Example content type.
200200
* @param opts Processing options.
201201
*/
202-
_generateFromExample(example: object, mime: String, opts?: ExampleOptions): Example|undefined;
202+
_generateFromExample(example: object, mime: String, opts?: ExampleOptions): Example | undefined;
203203

204204
/**
205205
* Computes list of examples for an array shape.
206206
* @param schema The AMF's array shape
207207
* @param mime Current mime type
208208
* @param [opts={}]
209209
*/
210-
_computeExampleArrayShape(schema: object, mime: string, opts?: ExampleOptions): Array<Example>|undefined;
210+
_computeExampleArrayShape(schema: object, mime: string, opts?: ExampleOptions): Array<Example> | undefined;
211211

212212
/**
213213
* Computes example for an `and` shape.
@@ -233,21 +233,22 @@ declare class ExampleGenerator extends AmfHelperMixin(Object) {
233233
* @param mime Current mime type
234234
* @param [opts={}]
235235
*/
236-
_computeUnionExamples(schema: object, mime: string, opts?: ExampleOptions): Array<Example>|undefined;
236+
_computeUnionExamples(schema: object, mime: string, opts?: ExampleOptions): Array<Example> | undefined;
237237

238238
/**
239239
* Computes value from defined `datatype` property.
240240
*
241241
* @param shape A shape with `datatype` property.
242242
* @returns Value of the data type.
243243
*/
244-
_computeScalarType(shape: object): string|undefined;
244+
_computeScalarType(shape: object): string | undefined;
245245

246246
/**
247247
* Creates a JSON example representation from AMF example's structure
248248
* definition.
249249
*/
250-
_jsonFromStructure(structure: object): any|undefined;
250+
_jsonFromStructure(structure: object): any | undefined;
251+
251252
/**
252253
* Creates a JSON object structure from an example.
253254
* This object is later on serialized to the example string value.
@@ -258,7 +259,7 @@ declare class ExampleGenerator extends AmfHelperMixin(Object) {
258259
* @param key Processed object's key
259260
* @param resolvedPrefix AMF's `data:` prefix
260261
*/
261-
_jsonFromStructureValue(value: Object|Array<any>|number|string, obj: Object|Array<any>, isArray: boolean, key?: string, resolvedPrefix?: string): void;
262+
_jsonFromStructureValue(value: Object | Array<any> | number | string, obj: Object | Array<any>, isArray: boolean, key?: string, resolvedPrefix?: string): void;
262263

263264
/**
264265
* Generates XML example string value from AMF's structured value definition.
@@ -272,7 +273,7 @@ declare class ExampleGenerator extends AmfHelperMixin(Object) {
272273
* @param structure Value of the `structuredValue` property of AMF's example object.
273274
* @return Value casted to a type
274275
*/
275-
_getTypedValue(structure: object): string|number|boolean|null;
276+
_getTypedValue(structure: object): string | number | boolean | null;
276277

277278
/**
278279
* Creates a example structure for the JSON schema.
@@ -292,22 +293,22 @@ declare class ExampleGenerator extends AmfHelperMixin(Object) {
292293
* @param typeName Name of the RAML type.
293294
* @param parentType For XML processing, parent type name in case of Array type.
294295
*/
295-
_exampleFromProperties(properties: object[], mime: string, typeName?: string, parentType?: string): Example|undefined;
296+
_exampleFromProperties(properties: object[], mime: string, typeName?: string, parentType?: string): Example | undefined;
296297

297298
/**
298299
* Generates a JSON example from RAML's type properties.
299300
*
300301
* @param properties List of type properties
301302
*/
302-
_jsonExampleFromProperties(properties: Array<object>): object|null|undefined;
303+
_jsonExampleFromProperties(properties: Array<object>): object | null | undefined;
303304

304305
/**
305306
* Computes JSON value from a range shape.
306307
*
307308
* @param range AMF's range model.
308309
* @param typeName Optional, type name to use in Union type. By default first NodeShape.
309310
*/
310-
_computeJsonPropertyValue(range: object, typeName?: string): any|undefined;
311+
_computeJsonPropertyValue(range: object, typeName?: string): any | undefined;
311312

312313
/**
313314
* Computes scalar value for AMF's range and casts it to the corresponding type.
@@ -317,7 +318,7 @@ declare class ExampleGenerator extends AmfHelperMixin(Object) {
317318
* @param range AMF's range definition for a shape.
318319
* @returns Value casted to the corresponding type
319320
*/
320-
_computeJsonScalarValue(range: object): string|number|boolean|null;
321+
_computeJsonScalarValue(range: object): string | number | boolean | null;
321322

322323
/**
323324
* Computes default value for given range.
@@ -330,7 +331,7 @@ declare class ExampleGenerator extends AmfHelperMixin(Object) {
330331
* @param range AMF's range definition for a shape.
331332
* @returns Value casted to the corresponding type
332333
*/
333-
_computeDefaultRangeValue(range: object): string|number|boolean|null;
334+
_computeDefaultRangeValue(range: object): string | number | boolean | null;
334335

335336
/**
336337
* Casts the value to given data type represented in AMF notation.
@@ -339,45 +340,45 @@ declare class ExampleGenerator extends AmfHelperMixin(Object) {
339340
* @param type AMF data type
340341
* @returns Casted value.
341342
*/
342-
_typeToValue(value: string, type: string): string|number|boolean|null;
343+
_typeToValue(value: string, type: string): string | number | boolean | null;
343344

344345
/**
345346
* Computes JSON example from UnionShape
346347
*
347348
* @param range Type definition
348349
* @param typeName Optional, type name to use. By default first NodeShape.
349350
*/
350-
_computeJsonUnionValue(range: object, typeName?: String): object|undefined;
351+
_computeJsonUnionValue(range: object, typeName?: String): object | undefined;
351352

352353
/**
353354
* Computes JSON object as an example from a range that is an object.
354355
*
355356
* @param range AMF's range definition for a shape.
356357
* @returns A JavaScript object computed from the properties.
357358
*/
358-
_computeJsonObjectValue(range: object): any|undefined;
359+
_computeJsonObjectValue(range: object): any | undefined;
359360

360361
/**
361362
* Computes JSON object as an example from a range that is an array.
362363
*
363364
* @param range AMF's range definition for a shape.
364365
* @return A JavaScript array computed from the items.
365366
*/
366-
_computeJsonArrayValue(range: object): object[]|undefined;
367+
_computeJsonArrayValue(range: object): object[] | undefined;
367368

368369
/**
369370
* Reads raw value of the example.
370371
* @param example AMF's example definition.
371372
* @return Raw example value.
372373
*/
373-
_extractExampleRawValue(example: Array<Object>|Object): String|undefined;
374+
_extractExampleRawValue(example: Array<Object> | Object): String | undefined;
374375

375376
/**
376377
* Gets a value from a Range shape for a scalar value.
377378
*
378379
* @param range AMF's range model.
379380
*/
380-
_getTypeScalarValue(range: object): string|number|boolean|null;
381+
_getTypeScalarValue(range: object): string | number | boolean | null;
381382

382383
/**
383384
* Computes example from a range's properties for XML media type.
@@ -449,7 +450,8 @@ declare class ExampleGenerator extends AmfHelperMixin(Object) {
449450
* @param property A property to read the name from. Usually range.
450451
* @return Normalized name or undefined if name is not defined.
451452
*/
452-
_getXmlNormalizedName(property: object): string|undefined;
453+
_getXmlNormalizedName(property: object): string | undefined;
454+
453455
/**
454456
* Adds elements to the node which are an array.
455457
*
@@ -485,7 +487,7 @@ declare class ExampleGenerator extends AmfHelperMixin(Object) {
485487
* @param model `structuredValue` item model.
486488
* @returns Javascript object or array with structured value.
487489
*/
488-
_computeExampleFromStructuredValue(model: object): object|object[]|null;
490+
_computeExampleFromStructuredValue(model: object): object | object[] | null;
489491

490492
/**
491493
* Computes value with property data type for a structured example.
@@ -516,4 +518,11 @@ declare class ExampleGenerator extends AmfHelperMixin(Object) {
516518
_processDataObjectProperties(doc: Document, node: Element, property: object): void;
517519

518520
_getTrackedValue(tracked: any): string;
521+
522+
/**
523+
* Generates XML example string value from AMF's structured value definition.
524+
* @param {Object} serialization Value of the `serialization` property of AMF's object.
525+
* @return {XmlData}
526+
*/
527+
_computeXmlSerializationData(serialization): object;
519528
}

0 commit comments

Comments
 (0)