Giter VIP home page Giter VIP logo

Comments (6)

ozscheyge avatar ozscheyge commented on August 28, 2024 1

Hey @pax95 ,

Spring restdocs tries to infer the type from the example bodies, but you can override this with:

fieldWithPath("featurings").type(JsonFieldType.ARRAY).description("List of featuring artist if any")

You need to use JsonFieldType types and not the Java types. I hope, this helps!

from restdocs-api-spec.

mduesterhoeft avatar mduesterhoeft commented on August 28, 2024

Sounds reasonable. I think this could be done by extending the PathDescriptor from spring-restdocs.

Would you be in to give it a try.

from restdocs-api-spec.

levippaul avatar levippaul commented on August 28, 2024

@mduesterhoeft yeah, I'd be happy to give it a shot. If there are any pointers that you can share to help me get started, that'd be great!

from restdocs-api-spec.

mduesterhoeft avatar mduesterhoeft commented on August 28, 2024

Looks like we already have that:

You can specify the type of a parameter using the type() method.

parameterWithName("otherId").description("otherId id").type(SimpleType.INTEGER)

.pathParameters(
                            parameterWithName("someId").description("some id"),
                            parameterWithName("otherId").description("otherId id").type(SimpleType.INTEGER)
                    )

from restdocs-api-spec.

pax95 avatar pax95 commented on August 28, 2024

Is there a similar way to specify a ARRAY type. Setting the type to java.util.List generates ->
{
"attributes" : { },
"description" : "List of featuring artist if any",
"ignored" : false,
"path" : "[].musicInfo.featurings[]",
"type" : "java.util.List",
"optional" : true
}
in resource.json where it should have been ARRAY

Update:
Found the answer in another issue. Just use JsonFieldType.ARRAY for array type it seems.

from restdocs-api-spec.

ozscheyge avatar ozscheyge commented on August 28, 2024

This should be working by now, see
#181 (comment) and the linked example:
https://github.com/ePages-de/restdocs-api-spec/pull/185/files#diff-672ed55d0ceac62de36f9aa7020d71ca27d6bbb03b9c0d7777699d21287191b5R298-R321

from restdocs-api-spec.

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.