mar...@gmail.com schrieb am Freitag, 4. September 2020 um 20:13:42 UTC+2:

> Oh wow, my email client showed your email in a truncated way, so i didn't 
> see you were already using my project, sorry for the silly response.
>
> It would be possible to add external type definitions to oapi-codegen, I 
> believe. I'm in the process of thinking about a v2 version which is more 
> stable, and less convoluted. V1 was a learning experience.
>

You project is awesome, I already use it!

My current workflow is as following:
1. I create my models in code. Thereby I embed structs of external packages.
2. As I am lazy and do not feel like re-creating all the OpenApi3 model 
definitions declaratively is use go-swagger, only using model annotations 
like // swagger:model and exporting the models only
3. As go swagger is stuck in OpenApi 2.0 I use a  sed - script to update 
the created YAML-models by go-swagger and fix the $refs to create a 
crippled yet valid OpenApi3 - spec 
4. I define my API using an OpenApi3 - editor. Currently I am using 
editor.swagger.io as it doesn't mess with external refs to models 
5. I scaffold  my go app using oapi-codegen and the newly added  
-import-mapping, treating my own model as an external ref (which it somehow 
is, as I am embedding external struct members)

Ugly hack, mostly because of go-swagger stuck in OpenApi2, but a hack that 
works :)
 

>
> On Fri, Sep 4, 2020 at 10:56 AM Marcin Romaszewicz <mar...@gmail.com> 
> wrote:
>
>> Have you considered reversing the workflow? You write the OpenAPI spec, 
>> and have a code generator produce the Schemas and server boilerplate?
>>
>> If that's ok, check out my project :) 
>> https://github.com/deepmap/oapi-codegen
>>
>> We successfully use it for many API's in production.
>>
>> -- Marcin
>>
>>
>> On Thu, Sep 3, 2020 at 12:06 AM Johann Höchtl <johann....@gmail.com> 
>> wrote:
>>
>>>
>>> Hi,
>>> I would like to accomplish the following:
>>>
>>> An existing golang package on github provides a struct definition I am 
>>> interested in to be used as part of a REST API interface I design
>>>
>>>    1. I would like to automatically go generate json schema for this 
>>>    struct
>>>    2. I would like to incorporate this generated schema into an OpenAPI 
>>>    definition and generate go boilerplate for that
>>>
>>>
>>> For step 2 I am using https://github.com/deepmap/oapi-codegen which 
>>> works great. It also supports $ref to external schemas.
>>>
>>> Still looking to accomplish step 1: I am searching for a tool which go 
>>> generates JSON schema from a golang source file or package. Any help?
>>>
>>> -- 
>>> You received this message because you are subscribed to the Google 
>>> Groups "golang-nuts" group.
>>> To unsubscribe from this group and stop receiving emails from it, send 
>>> an email to golang-nuts...@googlegroups.com.
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/golang-nuts/f0e099de-7008-478d-ba92-f2febd0c40bdn%40googlegroups.com
>>>  
>>> <https://groups.google.com/d/msgid/golang-nuts/f0e099de-7008-478d-ba92-f2febd0c40bdn%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/11ccd06c-9201-47bf-987d-6fe9584f495bn%40googlegroups.com.

Reply via email to