Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generated code is broken based on json. #176

Closed
bodiam opened this issue May 14, 2019 · 1 comment
Closed

Generated code is broken based on json. #176

bodiam opened this issue May 14, 2019 · 1 comment
Assignees
Labels
Milestone

Comments

@bodiam
Copy link

bodiam commented May 14, 2019

Hi all,

Based on the below JSON, the code generation is broken. It generates Kotlin constructors with duplicated commas, it adds trailing commas, etc.

For example, this is some of the code created:

data class Author(
        val name: String,     // <-- trailing comma is invalid code
        )

data class Image(
        val height: Int, ,      // <-- extra comma here is invalid code
        val url: String,
        val width: Int
)

This seemed to be caused by the fields prefixed with @ signs.

This is done based on the 3.2.0 plugin using this JSON:

{
  "recipeInstructions": [
    "Cook pasta in a pan of boiling salted water according to packet instructions. Drain, reserving 1 cup (250ml) liquid.",
    "Return pasta and liquid to pan with pecorino, pepper and half the butter. Stir to coat and keep warm.",
    "Melt remaining 40g butter in a frypan over high heat. Add mushrooms and sage.",
    "Cook, tossing, for 3-4 minutes until golden. Season and serve with pasta."
  ],
  "recipeIngredient": [
    "400g spaghetti (we used Woolworths Macro organic spaghetti)",
    "3 cups (240g) finely grated pecorino, plus extra to serve",
    "1 tbs crushed black peppercorns",
    "80g unsalted butter",
    "500g mixed mushrooms (such as Swiss brown and chestnut)",
    "1\/3 cup sage leaves"
  ],
  "recipeCuisine": "italian",
  "cookingMethod": null,
  "cookTime": "PT0S",
  "prepTime": "PT0S",
  "totalTime": null,
  "recipeYield": 4,
  "nutrition": {
    "calories": null,
    "fatContent": null,
    "saturatedFatContent": null,
    "carbohydrateContent": null,
    "sugarContent": null,
    "fibreContent": null,
    "proteinContent": null,
    "cholesterolContent": null,
    "sodiumContent": null,
    "@context": "http:\/\/schema.org",
    "@type": "NutritionInformation"
  },
  "aggregateRating": {},
  "recipeCategory": "dinner, main",
  "keywords": "Mushrooms, sage, butter, spaghetti, simple pasta, Italian flavours, Italian food, Italian cooking, Italian recipes, five ingredient pasta, 5 ingredient pasta, Phoebe Wood, mushroom pasta, cacio e pepe pasta, sage mushrooms, crispy sage, Vegetarian, Easy vegetarian, Vegetarian recipes, Vegetarian dinner, Vegetable mains, Meat free Monday, Meat-free Monday, Meat free mains, portobello mushrooms, roasted mushrooms, Fast food, Quick meals, Easy dinner, Easy recipes, Easy cooking",
  "name": "Cacio e pepe with sage mushrooms",
  "description": "Need a break from meat tonight? This simple vegetarian pasta is a winner. With just five ingredients, it's the perfect mid-week recipe to add to your weekly meal plan, yum!",
  "datePublished": "2016-06-10",
  "dateCreated": "2016-06-17",
  "mainEntityOfPage": null,
  "dateModified": "2019-01-23",
  "author": {
    "name": "Phoebe Wood",
    "@context": "http:\/\/schema.org",
    "@type": "person"
  },
  "publisher": {
    "name": null,
    "logo": null,
    "@context": "http:\/\/schema.org",
    "@type": "Organization"
  },
  "image": {
    "url": "https:\/\/img.delicious.com.au\/UvMnowlO\/del\/2016\/05\/cacio-e-pepe-with-sage-mushrooms-30645-1.jpg",
    "width": 1500,
    "height": 1000,
    "@context": "http:\/\/schema.org",
    "@type": "ImageObject"
  },
  "video": {
    "name": "5348771529001-5981831265001",
    "description": "5348771529001-5981831265001",
    "thumbnailUrl": "https:\/\/img.delicious.com.au\/UvMnowlO\/del\/2016\/05\/cacio-e-pepe-with-sage-mushrooms-30645-1.jpg",
    "uploadDate": "2019-01-23",
    "url": "https:\/\/resources.newscdn.com.au\/cs\/video\/vjs\/stable\/build\/index.html?id=5348771529001-5981831265001&=domain=del",
    "@context": "http:\/\/schema.org",
    "@type": "VideoObject"
  },
  "@context": "http:\/\/schema.org",
  "@type": "Recipe"
}
@wuseal wuseal added the bug label May 15, 2019
@wuseal
Copy link
Owner

wuseal commented May 15, 2019

@bodiam Thanks for your feedback, That's sure a bug, Will be fixed next version. the program may miss a deal with like @type property name

@wuseal wuseal added this to the 3.3.0 milestone May 20, 2019
wuseal pushed a commit that referenced this issue May 23, 2019
* fix #176

* remove code about "AutoReformat"
@wuseal wuseal added the fixed but not released this issue has been solved but is not released yet label May 24, 2019
@wuseal wuseal closed this as completed Jun 17, 2019
@wuseal wuseal removed the fixed but not released this issue has been solved but is not released yet label Jul 1, 2019
wuseal pushed a commit that referenced this issue Sep 20, 2021
* fix #176

* remove code about "AutoReformat"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants