Git Product home page Git Product logo

Comments (6)

eri-trabiccolo avatar eri-trabiccolo commented on August 24, 2024

Accidentally I was already only accepting the 'content' => string format when creating/updating. :D

from lifterlms-rest.

thomasplevy avatar thomasplevy commented on August 24, 2024

Good :-D

The spec needs to make this explicit though, carry on with your mistake I'm working on figuring out how to update the spec accordingly

from lifterlms-rest.

eri-trabiccolo avatar eri-trabiccolo commented on August 24, 2024

Yes sure, thanks!

from lifterlms-rest.

thomasplevy avatar thomasplevy commented on August 24, 2024

Documentation is unclear in WP Core but in practice it's possible to create/update a post with either of the following payloads for fields which return an object with rendered and raw properties:

{
    "content": "this is the raw html content"
}

Or:

{
    "content": {
       "raw": "this is the raw html content"
    }
}

So the updated spec will allow for both:

API_Reference___ReDoc
API_Reference___ReDoc

Example spec:

description: Post title.
oneOf:
  - type: string
    description: Raw title.
    example: Getting Started with LifterLMS
    writeOnly: true
  - type: object
    properties:
      rendered:
        type: string
        description: Rendered title.
        example: Getting Started with LifterLMS
        readOnly: true
      raw:
        type: string
        description: Raw title. Useful when displaying title in the WP Block Editor. Only returned in `edit` context.
        example: Getting Started with LifterLMS

from lifterlms-rest.

eri-trabiccolo avatar eri-trabiccolo commented on August 24, 2024

Mmm yeah I looked at the core code and actually wanted to ask if we wanted to replicate it, but then I thought that no, we didn't want to, why should we? :)
Anyway ok, will update the code to reflect this spec.
Basically the core code looks for the value of the field, if it's a string it will be used, otherwise the 'raw' nested field will be used (if set, of course).
https://github.com/WordPress/WordPress/blob/cf3fa9f7c8038447303eea1fbd3636c5fece28cd/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php#L982
(well you know better than me where to look)

from lifterlms-rest.

thomasplevy avatar thomasplevy commented on August 24, 2024

Spec ended up looking a little different than above. Documentation will not reflect the way this will work but lets follow the WP core as noted.

from lifterlms-rest.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.