Coder Social home page Coder Social logo

Comments (5)

mrlubos avatar mrlubos commented on June 18, 2024 1

@elibolonur do you generate spec from code or is it written manually? If code, are you able to share the snippet responsible for the piece that you shared?

EDIT: the original post is about literals not being treated as such and outputting any, but you're talking about an optional field, i.e. not the same issue

from openapi-typescript-codegen.

mrlubos avatar mrlubos commented on June 18, 2024 1

@DavidRowthorn @elibolonur this is fixed in the latest version of @nicolas-chaulet/openapi-typescript-codegen. If you're ending up with an optional field, you will need to mark it as required in your schema and that will resolve that problem!

from openapi-typescript-codegen.

mrlubos avatar mrlubos commented on June 18, 2024

@DavidRowthorn I'll need to see the spec you're using to generate the client, are you able to provide it? You can also try running your spec against our fork, this issue might be fixed there.

from openapi-typescript-codegen.

elibolonur avatar elibolonur commented on June 18, 2024

@mrlubos I have got the same issue on my end, tried even with your fork but Literal declarations are being generated as optional. However I am not sure if this is entirely generators fault as you see in the schema and not sure if this is somehow configurable during the schema generation.

{
  "Person":{
    "title":"Person",
    "type":"object",
    "properties":{
      "id":{
        "title":"Id",
        "type":"string"
      },
      "type":{
        "title":"Type",
        "default":"Young",
        "enum":[
          "Young"
        ],
        "type":"string"
      },
      "created":{
        "title":"Created",
        "type":"string",
        "format":"date-time"
      }
    },
    "required":[
      "id",
      "created"
      // type is not added as required here
      ...
      ...
    ]
  }
}

from openapi-typescript-codegen.

elibolonur avatar elibolonur commented on June 18, 2024

@mrlubos Unfortunately not able to share the full schema. This is the part that is treated as optional, with changed names. I could share this part with some changed names fully as well.

Also yes, it is not exactly the same. However it is probably still related since literal types are translated as optional anyway. Might not be related to the generator either as said.

from openapi-typescript-codegen.

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.