Closed robrechta closed 7 years ago
@robrechta you mentioned that you are using MSON. Could you please share that MSON structure.
okey, I don't see what the typed mson has to do with parsing a response, but I'll give it. I hope it helps :-)
## Beam block [/api/publishing/EXERCISE_BLOCK/e954cee0-c96f-42b9-b8dd-b2bab7788096]
### Get json [GET]
+ Response 200 (application/json)
+ Attributes (ExerciseBlock)
Data structure:
# Data Structures
## `time` (object)
+ `timed`: `false` (boolean)
+ `seconds`: `0` (number)
## `SingleChoiceOptions` (object)
+ `orderChoices`: `random` (string)
+ `numberOfAnswerOptions`: `2` (number)
## `SingleChoiceAnswer` (object)
+ `id`: `15777688` (number)
+ `text`: `<p>a</p>` (string)
+ `correct`: true (boolean)
+ `hint`: `<p>This is the hint information</p>` (string)
+ `theory`: '<p>This is the theory information</p>' (string)
## `Alias` (object)
- `value`: `banaan` (string)
- `caseSensitive`: `false` (boolean)
- `shownChars`: `0` (number)
- `inputByUser` (object)
## `InputAnswerOption` (object)
+ `groupIdentifier` : null (string, nullable)
+ `identifier` (object)
+ `inputAnswerIdentifier`: `#1` (string)
+ `inputByUser`: true (boolean)
+ `hidden`: false (boolean)
+ `hintFeedbackMode` (object)
+ `theoryFeedbackMode` (object)
+ `aliases` (array)
+ (Alias)
## `InputAnswerGroup` (object)
+ `name`: `Default` (string)
+ `inputAnswerOptions` (array)
+ (array)
+ (InputAnswerOption)
## `SingleChoiceExerciseAttributes` (object)
+ `exerciseType`: `single-choice` (string)
+ `question`: `<p>Some exercise question</p>` (string)
+ `time` (time)
+ `options` (SingleChoiceOptions)
+ `answers` (array)
+ (array)
+ (SingleChoiceAnswer)
+ `id`: `1000` (number)
+ `correct`: true (boolean)
+ (SingleChoiceAnswer)
+ `id`: `2000` (number)
+ `correct`: false (boolean)
## `BeamVisualizationAttributes` (object)
+ `visualizationType`: `beam` (string)
+ `colour`: `Laser_01_png` (string)
+ `emitter`: `Grade1_Emitter_png` (string)
+ `console`: `Grade1_Controller_Beam_png` (string)
## `instructionConfiguration` (object)
+ `sound` : null (string, nullable)
+ `questionLine1`: `<p>Duid het juiste antwoord aan</p>` (string)
+ `questionLine2` (string)
+ `readSpeakerType`: `DUTCH` (string)
## `ExerciseConfigProperties` (object)
+ `blockid`: `e954cee0-c96f-42b9-b8dd-b2bab7788096` (string)
+ `blockCode`: `ETSL beam` (string)
+ `exerciseAttributes` (SingleChoiceExerciseAttributes)
+ `visualizationAttributes` (BeamVisualizationAttributes)
+ `instructionConfiguration` (instructionConfiguration)
## `ExerciseConfig` (object)
+ `uniqueId`: `86982e0a7854faa6c1bd0f0a69105ce02f1c8869` (string)
+ `level`: `base` (string)
+ `group`: `6e8ca2e1-f7b5-41aa-9fd5-5e92c0922ed1` (string)
+ `groupCode`: `15750571` (string)
+ `properties` (ExerciseConfigProperties)
## `ContentPurpose` (object)
+ `key`: `contentPurpose` (string)
+ `value` (array[string])
## `NumberOfQuestions` (object)
+ `key`: `numberOfQuestions` (string)
+ `value`: `1` (number)
## `ConditionalSequencePattern` (object)
+ `key`: `conditionalSequencePattern` (string)
+ `value`
+ `base`: `2/2`
+ `remedial`: `2/2/3`
+ `enrichment`: `3/3`
## `BlockNumber` (object)
+ `key`: `blockNumber` (string)
+ `value`: `0` (number)
## `NameForTeacher` (object)
+ `key`: `nameForTeacher` (string)
+ `value`: `ETSL beam` (string)
## `NameForPupil` (object)
+ `key`: `nameForPupil` (string)
+ `value`: `ETSL beam` (string)
## `ConfigsRandomized` (object)
+ `key`: `configsRandomized` (string)
+ `value`: true (boolean)
## `RemedialPresent` (object)
+ `key`: `remedialPresent` (string)
+ `value`: true (boolean)
## `EnrichmentPresent` (object)
+ `key`: `enrichmentPresent` (string)
+ `value`: true (boolean)
## `RewardConfiguration` (object)
+ `key`: `rewardConfiguration` (string)
+ `value`
+ `correctAnswerAmount` (number)
+ `correctAnswerAfterFeedbackAmount` (number)
+ `wrongAnswerAmount` (number)
## ExerciseBlock
+ uniqueId: `e954cee0-c96f-42b9-b8dd-b2bab7788096` (string)
+ type: `digital` (string)
+ method: `4DF3CAD3-DED0-4507-A537-462831C915CD` (string)
+ year: `ED34E063-1E1F-4C9B-AE57-B21FB9A21332` (string)
+ chapter: `E5D39EF3-3BEC-4C72-BFAD-D6C74FAE8B1A` (string)
+ subject: `D992DBDB-CF28-44A6-8839-CAC282A4993A` (string)
+ subtopic: `Ip6KTtTxRlSkRWil3XEOxQ` (string)
+ payable: `false` (boolean)
+ content (array)
+ (ContentPurpose)
+ (object)
+ `key`: `configs` (string)
+ `value` (array)
+ (ExerciseConfig)
+ (NumberOfQuestions)
+ (ConditionalSequencePattern)
+ (BlockNumber)
+ (NameForTeacher)
+ (NameForPupil)
+ (ConfigsRandomized)
+ (RemedialPresent)
+ (EnrichmentPresent)
+ (RewardConfiguration)
The specific message At '' Invalid type: string (expected object)
I believe is regarding validating the response against the JSON Schema (derived from the MSON).
Let me dig into this and try and reproduce, I'll get back to you once I know more.
@robrechta Could it be possible that your production is returning double JSON encoded response? I.e, it's returning a JSON string which is serialised JSON.
exports.endpoint = function(request, response) {
response.end(JSON.stringify(JSON.stringify({"test": "test"})));
}
$ curl https://untitled-5qqqzw6bm1rr.runkit.sh
"{\"test\":\"test\"}"
The only way I can reproduce similar behaviour is while doing so. Otherwise perhaps there could be a problem on Apiary side and there is some way that the response is getting coerced to JSON.
@kylef I thought that too, but when requesting the json in a browser, the json is like {"test": "test"}
....
Ha, you are using curl to verify.
....
Damned, when I trying to use curl it is like you said: "{\"uniqueId\":\"e46bc6c1-3db9-4086-9bf5-abf87572cdeb\"
... don't know why I didn't see that in chrome or firefox...
Ok, I can fix the backend that builds the json, and see what happens... I'll keep you posted...
@kylef it is fixed on our side, thx for the support. Edit (for anybody else who read this): The backend is a spring project, and we stumbled againts: https://stackoverflow.com/questions/15507064/return-literal-json-strings-in-spring-mvc-responsebody Adding a stringHttpMessageConverter before jackson solved the issue.
I'm trying to document a certain json response. Somehow, I'm unable to compare my documented mson against the production json. When I launch the url, in the response: the json is somehow a String. When I launch compare, I'm getting the message
At '' Invalid type: string (expected object)
. This is the json that is returned by my application:The body that is shown in the apiary (online editor)
When I go to the inspector, then the response body that is shown is a little bit smaller then expected:
--> the "content" object with key 'contentPurpose' his value is missing, and all the other objects in "content" are missing. The Json seems valid to me, so I don't know what's going wrong...
Some screenshots that illustrate the problem: Calling api Compare Inspector