Giter Club home page Giter Club logo

Comments (11)

michalig avatar michalig commented on May 18, 2024

Hi I've prepared a fix for that. Please check my branch:
https://github.com/michalig/swagger-maven-plugin

Now you can configure overridingModels in apiSource configuration:

<apiSource>
    ...
    <overridingModels>/swagger-overriding-models.json</overridingModels>
</apiSource>

Example swagger-overriding-models.json:

{
    "mapping" :
    {
        "className" : "org.joda.time.DateTime",
        "jsonString" : "{\"id\": \"Date\",\"properties\": {\"value\": {\"required\": true, \"description\": \"Date in ISO-8601 format\", \"notes\": \"Add any notes you like here\", \"type\": \"string\", \"format\": \"date-time\"}}}"
    }
}

from swagger-maven-plugin.

kongchen avatar kongchen commented on May 18, 2024

Thanks for the patch!

from swagger-maven-plugin.

jianlans avatar jianlans commented on May 18, 2024

I have tried using the json override using the same swagger-overriding-models.json in sample project (just copied the file) but keep getting compiler error:

[ERROR] Failed to execute goal com.github.kongchen:swagger-maven-plugin:2.3.1:generate (default) on project swagger-maven-example: Swagger-overridingModels[/Users/jsong/dps-repo/swagger-maven-example/src/main/resources/swagger-overriding-models.json] must be a valid JSON file! No content to map due to end-of-input
[ERROR] at [Source: UNKNOWN; line: 1, column: 1]

Any suggestion what may be the problem?

from swagger-maven-plugin.

michalig avatar michalig commented on May 18, 2024

Can you please paste your swagger-overriding-models.json file?

from swagger-maven-plugin.

jianlans avatar jianlans commented on May 18, 2024

Here is the json file:

{
"mapping" :
{
"className" : "com.github.kongchen.swagger.sample.wordnik.model.Pet",
"jsonString" : "{"id": "MediaType","properties": {"value": {"required": true, "description": "Content-Type in HTTP request/response header", "notes": "Add any notes you like here", "type": "string", "format": "/"}}}"
}
}

Basically I copied the same json file from swagger-maven-plugin project and just changed class name.

from swagger-maven-plugin.

jianlans avatar jianlans commented on May 18, 2024

BTW, I also tried sample project https://github.com/kongchen/swagger-maven-example. After fixing the path in the pom.xml to point to the correct json file, I got the same error with no change to the source.

from swagger-maven-plugin.

michalig avatar michalig commented on May 18, 2024

Looks fine. Check if overridingModels path is set correctlly in pom.xml.

from swagger-maven-plugin.

jianlans avatar jianlans commented on May 18, 2024

for project https://github.com/kongchen/swagger-maven-example, I modified the path to:
${basedir}/src/main/resources/swagger-overriding-models.json

Is it correct?

from swagger-maven-plugin.

michalig avatar michalig commented on May 18, 2024

Try using just the "/swagger-overriding-models.json" part.

from swagger-maven-plugin.

jianlans avatar jianlans commented on May 18, 2024

Full setting for overridingModels element in pom.xml:
${basedir}/src/main/resources/swagger-overriding-models.json

from swagger-maven-plugin.

jianlans avatar jianlans commented on May 18, 2024

using "/swagger-overriding-models.json" does not seem to pick up the json. The output json does not contain the custom definition for Pet.

from swagger-maven-plugin.

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.